当前位置:网站首页>C#泛型_泛型类
C#泛型_泛型类
2022-06-22 13:04:00 【苍狼王unity学院】
1、T代表一个数据类型,当使用classA进行构造的时候,需要制定T的类型
class ClassA<T,A> {//T代表一个数据类型,当使用classA进行构造的时候,需要制定T的类型
private T a;
private T b;
private A c;
public ClassA(T a, T b )
{
this.a = a;
this.b = b;
}
public string GetSum()
{
return a +""+ b;
}
}2、当我们利用泛型类构造的时候,需要指定泛型的类型
class Program {
static void Main(string[] args) {
//var o1 = new ClassA<int>(12,34);//当我们利用泛型类构造的时候,需要制定泛型的类型
//string s = o1.GetSum();
//Console.WriteLine(s);
var o2 = new ClassA<string,int>("wwww.","zx.cm");
Console.WriteLine(o2.GetSum());
Console.ReadKey();
}
}边栏推荐
- 成都测试设备开发_单片机C语言之数组介绍
- Seven cattle cloud upload picture
- Technology practice | scene oriented audio and video call experience Optimization
- 测试组的任务职责和测试的基本概念
- Query escape in Oracle expdp export
- 安装和使用protobuf-c
- Some common SQL (version 05 and above) database maintenance scripts
- Number of times Oracle uses cursor to decompose numbers
- 简简单单的科研秘籍
- Are you familiar with redis cache of highly paid programmers & interview questions series 114? How are redis keys designed? Are you familiar with the memory obsolescence mechanism?
猜你喜欢

能让Jellyfin直接挂载阿里云盘的aliyundrive-fuse

Instanceinforeplicator class of Eureka (service registration auxiliary class)

My suggestions on SAP ABAP transformation

“不敢去懷疑代碼,又不得不懷疑代碼”記一次網絡請求超時分析

Neuron+ekuiper realizes data collection, cleaning and anti control of industrial Internet of things

VCIP2021:利用解码信息进行超分辨率

Stm32f1 and stm32subeide programming example - Optical intermittent sensor drive

"N'osez pas douter du Code, vous devez douter du Code" notez une analyse de délai de demande réseau

防火墙基础之策略部署

Flink状态管理
随机推荐
Flink状态管理
Shan Zhiguang, chairman of BSN Development Alliance: DDC can provide the underlying support for the development of China's meta universe industry
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
Offline physical stores combined with VR panorama make virtual shopping more realistic
Implementation of redis+caffeine two-level cache
polardbx是pg还是mysql?
BSN发展联盟理事长单志广:DDC可为中国元宇宙产业发展提供底层支撑
Oracle's skills in dealing with inserting duplicate records
Transformers vit image model vector acquisition
"N'osez pas douter du Code, vous devez douter du Code" notez une analyse de délai de demande réseau
坚持了 10 年的 9 个编程好习惯
谈谈人生风控
Database employment consulting system for your help
VR panoramic shooting breaks the deadlock of traditional propaganda that wild geese pass without leaving traces
位置编码(PE)是如何在Transformers中发挥作用的
《Kubernetes监控篇:Grafana通过自动化方式添加datasource和dashboard》
Tables converting to latex format
30岁之前一定要明白的道理
Double hands of daily practice of Li Kou 2day9
Seven cattle cloud upload picture