您的位置:首页 > 编程语言 > C#

C#对象初始或器-Chapter3 P38

2015-10-22 13:04 453 查看

 

 

 

protected string GetMessage()
{
//如何构造和初始化泛型集合库中的一个数组和两个类。
Product myProduct = new Product{ProductID=100,Name="Kayak",Description ="A boat for one person",Price=275M,Category="Watersports"};
return String.Format("Category:{0}", myProduct.Category);
string[] stringArray = { "apple", "orange", "plum" };
List<int> intList = new List<int> { 10, 20, 30, 40 };
Dictionary<string, int> myDict = new Dictionary<string, int> { { "apple", 10 }, { "orange", 20 }, { "plum", 30 } };
return String.Format("fruit:{0}", (object)stringArray[1]);
}

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: