官术网_书友最值得收藏!

The ExtensionMethods class

This newly added class provides an easy to use an extension method to return all of the properties in a class except the label. If you are unfamiliar with extension methods, these methods provide a very simple syntax to potentially provide complex actions on a single object, like in this case, where we take an arbitrary type and return all of the properties it contains (except for labelName):

using System;
using System.Linq;

namespace chapter03.Common
{
public static class ExtensionMethods
{
public static string[] ToPropertyList<T>(this Type objType, string labelName) => objType.GetProperties().Where(a => a.Name != labelName).Select(a => a.Name).ToArray();
}
}
主站蜘蛛池模板: 兴业县| 嘉兴市| 河东区| 贡嘎县| 永康市| 盐源县| 九台市| 石台县| 菏泽市| 惠安县| 白朗县| 兰溪市| 和硕县| 基隆市| 侯马市| 柘荣县| 穆棱市| 阜平县| 驻马店市| 龙海市| 博湖县| 疏勒县| 新源县| 万全县| 凤阳县| 南江县| 扶绥县| 汽车| 肇东市| 蓝田县| 望城县| 武强县| 克拉玛依市| 临高县| 珲春市| 长治市| 库尔勒市| 汤阴县| 兴安县| 祁连县| 长乐市|