打赏

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
posted @ 2019-05-08 16:48  刘奇云  阅读(7417)  评论(0编辑  收藏  举报