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]); }
相关文章推荐
- c# 基本值类型及其默认值
- c#网页截图
- c#Task类。实现异步的一种方式
- C# 模拟web Get,Post
- C#中调用百度地图API应用(.net&nb…
- C# 多线程(二)
- C# 多线程(一)
- C# 图形图像
- C# 绘制曲线(一)
- 深入C#内存管理来分析值类型&…
- C#异常处理
- C#定义类
- 谈C#中的Delegate
- Head First C# 实验室 赛狗日
- C#属性升级版--自动属性-chapter 3 P34-36
- C#的async和await
- 【整理】c# 调用windows API(user32.dll)
- C# 窗口优化扩展
- C# 获取系统时间及时间格式
- Leetcode-201- Bitwise AND of Numbers Range