开发者

Is C# optimizing overloaded methods called in cascade?

I have some code like that:

class MainApplication {

    protected static string _since;

    protected static void updateSince()
    {
        MainApplication.updateSince(DateTime.Now);
    }

    public static void updateSince(DateTime since)
    {
        开发者_开发问答MainApplication.updateSince(since.ToString("yyyy-MM-dd HH:mm:ss"));
    } 

    public static void updateSince(string since)
    {
        // finally, doing something real
        MainApplication._since = since;
    }

    /* ... */  

}

And I wonder if and how C# optimizes such cascade call?


No, C# doesn't optimize stuff at all. What you are asking is, whether the compiler optimizes this...
The compiler doesn't "optimize" this. You can verify this when you have a look at the generated IL code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜