vb.netperformanceoptimization

Does making a class NotInheritable in VB.NET offer the same (potential) compiler optimizations as sealed in C#?


I've read that making a class sealed in C# is advisable in high-performance scenarios because it frees the compiler to make certain optimizations (e.g., inlining property getters) that it wouldn't be able to make otherwise. Is the same true for NotInheritable in VB.NET? My guess would be yes, but I'm posting this question in case someone else has already investigated and happens to know the answer.


Solution

  • Yes, the generated IL for sealed in C# is identical to NotInheritable in VB.NET and those potential optimizations will be done by the JIT compiler which will happen regardless of the original language.