结构

初始化结构  可以不指定数据类型用尖括号<R>   后面要有的时候在声明数据类型

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace Mains
 8 {
 9     public class Person<R>
10     {
11         public R Name { get; set; }
12     }
13 }

调用

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace Mains
 8 {
 9     class Program
10     {

11         static void Main(string[] args)
12         {
13             #region For
14             List<string> list = new List<string>();
15             list.Add("李小龙");
16             list.Add("成龙");
17             list.Add("李霞");
18             //for (int i = 0; i <list.Count; i++)
19             //{
20 
21             //修改结合中元素  将“巩俐”    改成  “张靓颖”
22 
23             //    if (list[i].Equals("成龙"))
24             //    {
25             //        list[i] = "张靓靓";
26             //    }
27             //    Console.WriteLine(list[i]);
28             //}
29             //方案二:foreach
30             /*string:集合中单个元素的类型
31               item:迭代变量 ,集合中一项
32               in:语法规范
33               list:集合名称
34              */
35             foreach (string  item in list )
36             {
37                 Console.WriteLine(item);
38             }
39             //为什么集合或者数组可以使用foreach遍历?????
40             //解析:接口 和接口的初次遇见!!!
41             //    接口  第二个和接口的邂逅
42             //      接口  Java多态:第三次 : 和接口的缘分
43             //     接口  框架:
44             Console.ReadLine();
45 
46             #endregion
47         }
48     }
49 }

 

posted @ 2016-04-06 21:10  吴玄坤  阅读(155)  评论(0编辑  收藏  举报