日期:2014-05-18 浏览次数:21011 次
public class 车
{
public string 轮子个数{get; set;}
}
public class 单车: 车
{
public string 轮子个数{get; set;}
public string 是否可以变速 {get; set;}
}
public class 汽车: 车
{
public string 轮子个数{get; set;}
public string 自动挡还是手动挡{get;set;}
}
public class 检测类
{
public void 检测车辆轮子数(车 obj){
Console.Write(obj.轮子个数);
}
}
单车 bike = new 单车(); 检测类.检测车辆轮子数(bike);
public static object Convert(List<Models.CommonDataDetailModel> entities)
{ return obj; }
------解决方案--------------------
public class 检测类
{
public static void 检测车辆轮子数<T>(List<T> objs) where T : 车
{
foreach (车 obj in objs)
{
Console.WriteLine(obj.轮子个数);
}
}
}
检测类.检测车辆轮子数<单车>(new List<单车>());