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

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();
}
}
主站蜘蛛池模板: 渑池县| 界首市| 新宁县| 铜鼓县| 芦溪县| 象山县| 金华市| 黄冈市| 丰顺县| 鄱阳县| 瑞金市| 丹东市| 观塘区| 红原县| 浦江县| 临潭县| 康马县| 江都市| 陕西省| 安阳县| 新兴县| 怀宁县| 乌鲁木齐县| 广汉市| 龙江县| 广宁县| 赤城县| 新宁县| 礼泉县| 中超| 安福县| 濮阳市| 稻城县| 墨竹工卡县| 沽源县| 仁怀市| 连州市| 康乐县| 扶风县| 玉树县| 礼泉县|