C# Compiler optimization - Unused methods

后端 未结 4 1072
Happy的楠姐
Happy的楠姐 2020-12-06 10:14

Does C# compiler (in VS2008 or VS2010) remove unused methods while compiling ?

I assume that it may have a problem deciding if public methods will ever be used, so I

4条回答
  •  情深已故
    2020-12-06 10:45

    This optimization is effectively implemented at the JIT level, which is good because then it works for both public/private/whatever methods. If a method is never called (ignoring ngen, etc.), it never gets JITed. Now you might say that this is still a waste of space for metadata etc. but as others have pointed out, private isn't so private.

提交回复
热议问题