您的位置:首页 > 其它

属性设置的一些异常行为(二)

2013-05-14 19:34 381 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConTest
{
class Pan
{

public string Name { get; set; }
public double Price { get; set; }
public int Total { get; set; }

/// <summary>
/// 深圳平底锅的价格信息
/// </summary>
public static Pan SZ
{
get
{
return new Pan() {Name="深圳",Price=45.5,Total=100,};
}
}

/// <summary>
/// 上海平底锅的价格信息
/// </summary>
public static Pan SH
{
get
{
return new Pan() { Name = "上海", Price = 46.5, Total = 150, };
}
}

/// <summary>
/// 北京平底锅的价格信息
/// </summary>
public static Pan BJ
{
get
{
return new Pan() { Name = "北京", Price = 48.2, Total = 80, };
}
}

/// <summary>
/// 广州平底锅的价格信息
/// </summary>
public static Pan GZ
{
get
{
return new Pan() { Name = "广州", Price = 43.5, Total = 250, };
}
}
public Pan()
{

}

public Pan(string name ,double price,int total)
{
this.Name = name;
this.Price = price;
this.Total = total;
}

}

}

List<Pan> pans = new List<Pan>() { Pan.BJ, Pan.GZ, Pan.SH, Pan.SZ };
Console.WriteLine("四大城市平底锅的价格基本信息如下:");
foreach (var item in pans)
{
Console.WriteLine("地区:" +item.Name+ "\t平底锅价格:" + item.Price + "\t销量:" + item.Total);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐