zoukankan      html  css  js  c++  java
  • 结构

    初始化结构  可以不指定数据类型用尖括号<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 }
  • 相关阅读:
    建立自己的影响力
    在病房垒代码
    知乎确实不错
    不在乎你用到了什么技术,而在于你提供了哪些有价值的东西
    oschina上有不少好的项目
    我为何坚守Java?
    掌握了学习方法才能学到更多知识
    Jrebel实现Jetty 热部署
    互联网到底能干什么?我们还能干些什么?
    centos 阿里云 安装VNC Viewer
  • 原文地址:https://www.cnblogs.com/WuXuanKun/p/5361140.html
Copyright © 2011-2022 走看看