说实在的 我也不懂这些  只是知道用

今天看新项目的代码  基本上是用的这个

自己写了一个小实例  贴上来 怕忘记的时候找不到了

 

代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Test
<string> t1 = new Test<string>();
Response.Write(t1.GetValue(
"d1"));
//输出 d1 System.String
Test<int> t2 = new Test<int>();
Response.Write(t2.GetValue(
33));
//输出 33 System.Int32
}


}

public class Test<T>
{
public string GetValue(T _value)
{
Func
<T, string> fun = e => e+" "+e.GetType().ToString() + "<br />";
return fun(_value);
}
}

 

相关文章:

  • 2022-01-28
  • 2021-12-08
  • 2021-06-06
  • 2022-12-23
  • 2021-07-28
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-18
  • 2021-08-24
  • 2022-12-23
  • 2021-06-28
  • 2021-08-05
相关资源
相似解决方案