- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace 泛型
- {
- class 泛型的特性
- {
- public static void Main()
- {
- //泛型类的特性4 静态成员
- Person<string>.Name = "aladdin";
- Person<int>.Name = "zhao";
- Console.WriteLine( Person<string>.Name ); //aladdin
- Console.WriteLine( Person<int>.Name); // zhao
- //泛型类的静成成员,只对实例共享。以上操作其实可以看做是两个类
- Console.ReadLine();
- }
- }
- class Person<T>
- {
- public static string Name;
- }
- class Person
- {
- public static string Name;
- }
- }
C#中泛型特性4-静态成员
最新推荐文章于 2020-05-11 10:10:12 发布