class Program
{
static void Main(string[] args)
{
List<Cat> Cats = new List<Cat>
{
new Cat(){Name="aaa",Age=18},
new Cat(){Name="bbb",Age=11},
null
};
foreach (Cat c in Cats)
{
if (c != null)
{
Console.WriteLine(c.Name);
}
else
{
Console.WriteLine("null");
}
}
Console.ReadLine();
}
}
class Cat
{
public int Age { get; set; }
public string Name { get; set; }
}

 

結果:

List泛型  

1478679236546    

arrow
arrow
    全站熱搜

    Hugo Liu 發表在 痞客邦 留言(1) 人氣()