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.
精彩评论