当前位置:网站首页>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();
}
}边栏推荐
- Nansen Annual Report
- My suggestions on SAP ABAP transformation
- Rongyun: let the bank go to the "cloud" easily
- Performance of recommender algorithms on top-N recommendation tasks
- Kubernetes monitoring: grafana adds datasource and dashboard through automation
- Summary of patent blog writing
- Growth knowledge network
- hw在即,你还不会看危险报文?
- Query rewriting for opengauss kernel analysis
- How many days are there between the two timestamps of PHP
猜你喜欢
![[cloud native] event publishing and subscription in Nacos -- observer mode](/img/0f/34ab42b7fb0085f58f36eb67b6f107.png)
[cloud native] event publishing and subscription in Nacos -- observer mode

Understand the quality assurance of open source software (OSS)

Nine good programming habits for 10 years

Technology practice | scene oriented audio and video call experience Optimization

防火墙基础之策略部署

轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷

BSN发展联盟理事长单志广:DDC可为中国元宇宙产业发展提供底层支撑

Policy deployment of firewall Foundation

线下实体店结合VR全景,让虚拟购物更加真实

VR panoramic shooting breaks the deadlock of traditional propaganda that wild geese pass without leaving traces
随机推荐
Record of problems encountered in dual network card binding
如何实现接口异常场景测试?测试方法探索与测试工具实现
金融应用如何解决金额精度问题(以Quorum、golang为例)
Aliyundrive fuse that allows jellyfin to directly mount alicloud disks
Oceanbase database helps the ideal automobile intelligent production line to realize automatic recovery within 30 seconds
Technology practice | scene oriented audio and video call experience Optimization
技术实践 | 场景导向的音视频通话体验优化
浅析Redis 切片集群的数据倾斜问题
Query escape in Oracle expdp export
client-go gin的简单整合九-Create
JasperReport报表生成工具的基本使用和常见问题
Messari annual report-2022
Neuron+ekuiper realizes data collection, cleaning and anti control of industrial Internet of things
“不敢去懷疑代碼,又不得不懷疑代碼”記一次網絡請求超時分析
Cve-2022-22965 reappearance
什么是Bout?
Flink状态管理
毕业论文写作中致谢词的常见写法及优秀范文
融云:让银行轻松上“云”
Ppt data collection methods and analysis skills