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

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();
}
}
主站蜘蛛池模板: 景谷| 永新县| 万州区| 封丘县| 芦山县| 聂荣县| 石台县| 乳源| 吴江市| 南川市| 桦川县| 青田县| 紫金县| 丹棱县| 昌都县| 日土县| 夏津县| 喀什市| 偃师市| 阿图什市| 凤庆县| 和田县| 舟山市| 静乐县| 湖口县| 长宁区| 射阳县| 繁峙县| 余江县| 莲花县| 徐闻县| 凤阳县| 交城县| 鸡西市| 霸州市| 岱山县| 郸城县| 安远县| 鄯善县| 平潭县| 双鸭山市|