分类目录

链接

2024 年 4 月
1234567
891011121314
15161718192021
22232425262728
2930  

近期文章

热门标签

新人福利,免费薅羊毛

c# 反射赋值扩展方法

public static T ToModel<T>(this object source) where T : class, new() { var target = new T(); if (source == null) return null; foreach (var property in target.GetType().GetProperties()) { var sourceProterty = source.GetType().GetProperty(property.Name); if (sourceProterty == null) { continue; }   var propertyValue = sourceProterty.GetValue(source, null);   if (propertyValue != null) {   //property.SetValue(target, i, null); target.GetType().InvokeMember(property.Na...

.NET 暂无评论 阅读(1,375)

.NET泛型中的ForEach扩展方法源码

今天在使用ForEach的时候,不知道内部是用的FOR还是ForEach,于是想看看它的源码实现, F12找到地址, #region 程序集 mscorlib.dll, v4.0.30319 // C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\mscorlib.dll #endregion 打开后发现,空空如也!!如图:   于是就动手简单写了下,理解应该是用的FOREACH,如下:         /// <summary>         /// Each,ForEach,叫什么无所谓了         /// </summary>         public static void Each&l...

.NET 评论(2) 阅读(3,793)