using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TongYongClass
{
class Program
{
/// <summary>
/// 通用处理类
/// </summary>
/// <typeparam name="T">自定义类型</typeparam>
/// <param name="list">传输过来的对象那集合</param>
public static void ProcessList<T>(List<T> list) where T : class
{
//循环输出
foreach (var item in list)
{
Console.WriteLine((item as User).Id);
Console.WriteLine((item as User).Name);
}
}
static void Main(string[] args)
{
//这些我就不解释了
List<User> list = new List<User>();
User user = new User()
{
Id=1,
Name="小赵"
};
list.Add(user);
ProcessList<User>(list);
}
}
/// <summary>
/// 用户实体
/// </summary>
class User
{
public int Id { get; set; }
public string Name { get; set; }
}
}
就是一个处理而已,方便自己和大家使用,日后再加详细解说
\