Stylist stylist1 = new Stylist(); // creates new stylist
stylist1.FirstName = "john";
stylist1.LastName = "smith";
stylist1.Phone = "123456789";
stylist1.Email = "js@123.456";
stylist1.Rate = "123";
Stylist stylist2 = new Stylist(); // creates new stylist
stylist2.FirstName = "jane";
stylist2.LastName = "doe";
stylist2.Phone = "987654321";
stylist2.Email = "jd@987.654";
stylist2.Rate = "456";
List<Stylist> stylists = new List<Stylist>(); // creates stylist
list
stylists.Add(stylist1);
stylists.Add(stylist2);
我想在控制台中显示列表的内容,但我只想显示FirstName和LastName,我该怎么做呢?我也做了一个叫做Stylist的定制类
public class Stylist
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Rate { get; set; }
}
相关分类