/// <summary>
/// 为指定对象分配参数
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="dic">字段/值</param>
/// <returns></returns>
public static T Assign<T>(Dictionary<string, string> dic) where T : new()
{
Type myType = typeof(T);
T entity = new T();
var fields = myType.GetProperties();
string val = string.Empty;
object obj = null;
foreach (var field in fields)
{
&nb
C# 利用反射动态将字符串转换成属性对应的类型值
最新推荐文章于 2022-10-29 08:51:39 发布