Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Reflectionを使用せずにdotnetのコードからプロパティ名を取得することは可能ですか?
int PropWithNiceName { get {Console.Writeline( ??? )} }
はい; [CallerMemberName]新しい属性を使用できます。
[CallerMemberName]
static string MemberName([CallerMemberName] string name = null) { return name; } int MyProperty { set { Console.WriteLine(MemberName()); } }