C#nameof用法
1.实现代码
using System; namespace NameofUsage { /// <summary> /// C# nameof用法 /// </summary> internal class Program { private static void Main() { Console.Title = "C# nameof用法"; Person p = new Person(); Console.WriteLine(nameof(p)); Console.WriteLine(nameof(p.Name)); Console.WriteLine(nameof(Person.CreateDateTime)); Console.ReadKey(); } } public class Person { public long Id { get; set; } public string Name { get; set; } public DateTime CreateDateTime { get; set; } } }
2.运行效果
from:https://www.cnblogs.com/LifeDecidesHappiness/p/9857449.html