最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C# 獲取屬性名的方法

 更新時(shí)間:2013年03月01日 11:11:33   作者:  
C# 獲取屬性名的方法實(shí)例,需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication
{
    class Program
    {
        class Test
        {
            public string PropertyJustForTest1 { get; set; }
            public Test PropertyJustForTest2 { get; set; }
        }
        static void Main(string[] args)
        {
            Test test = new Test();
            Console.WriteLine(GetPropertyNameHelper.GetPropertyName<object>(() => test.PropertyJustForTest1));
            Console.WriteLine(GetPropertyNameHelper.GetPropertyName<object>(() => test.PropertyJustForTest2));
        }
    }
    static class GetPropertyNameHelper
    {
        public static string GetPropertyName<T>(Expression<Func<T>> express)
        {
            var memberExpress = express.Body as MemberExpression;
            if (memberExpress != null)
            {
                return memberExpress.Member.Name;
            }
            else
            {
                return string.Empty;
            }
        }
    }
}

相關(guān)文章

最新評(píng)論

海晏县| 乌拉特后旗| 镇康县| 余姚市| 新疆| 读书| 科技| 延长县| 三江| 和田县| 措美县| 会同县| 禹城市| 洪泽县| 原平市| 永德县| 临澧县| 措美县| 肥城市| 虎林市| 科技| 崇左市| 交城县| 临洮县| 甘孜县| 淳安县| 稻城县| 阿巴嘎旗| 香格里拉县| 平舆县| 千阳县| 乌拉特中旗| 都江堰市| 赤峰市| 沂源县| 斗六市| 绥棱县| 黄梅县| 福泉市| 屏东县| 新巴尔虎右旗|