结构

初始化结构  可以不指定数据类型用尖括号<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 }

 

转载于:https://www.cnblogs.com/WuXuanKun/p/5361140.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值