- Hands-On Machine Learning with ML.NET
- Jarred Capellman
- 102字
- 2021-06-24 16:43:32
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();
}
}
推薦閱讀
- Java語言程序設計
- 一步一步學Spring Boot 2:微服務項目實戰
- Deploying Node.js
- Objective-C Memory Management Essentials
- Design Principles for Process:driven Architectures Using Oracle BPM and SOA Suite 12c
- Arduino by Example
- Web Application Development with MEAN
- 程序員修煉之道:通向務實的最高境界(第2版)
- 精通Python設計模式(第2版)
- 區塊鏈技術進階與實戰(第2版)
- 交互式程序設計(第2版)
- Go語言入門經典
- Hacking Android
- AI自動化測試:技術原理、平臺搭建與工程實踐
- Java程序設計教程