Compile Time Reflection in C#

前端 未结 4 794
鱼传尺愫
鱼传尺愫 2020-12-13 09:55

I frequently write C# code that has to use magic strings to express property names. Everyone knows the problems with magic strings. They are very difficult to refactor, they

4条回答
  •  伪装坚强ぢ
    2020-12-13 10:44

    In C# 6.0, a new operator, nameof, is being added that will allow you to get the names of properties, classes, fields, events, and variables at compile time.

    Link to the design notes

    No more reflection for information the compiler already knows at design time!

提交回复
热议问题