当前位置:网站首页>C#中的泛型T的应用
C#中的泛型T的应用
2022-06-09 20:25:00 【charlsdm】
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp10
{
class TestClass<T>
{
public T value;
}
class TestClass2<T1,T2,K,M,LL,Key,Value>
{
public T1 value1;
public T2 value2;
public K value3;
public M value4;
public LL value5;
public Key value6;
public Value value;
}
interface TestInterface<T>
{
T Value
{
get;
set;
}
}
class Test : TestInterface<int>
{
public int Value {
get; set; }
}
class Test2
{
public void TestFun<T>(T value)
{
Console.WriteLine(value);
}
public void TestFun<T>()
{
T t = default(T);
}
public T TestFun<T>(string v)
{
return default(T);
}
public void TestFun<T,K,M>(T t,K k,M m)
{
}
}
class Test2<T>
{
public T value;
public void TestFun<K>(K k)
{
}
public void TestFun(T t)
{
}
}
class ArrayList<T>
{
private T[] array;
public void Add(T value)
{
}
public void Remove(T value)
{
}
}
class Program
{
static void Main(string[] args)
{
TestClass<int> t = new TestClass<int>();
t.value = 10;
Console.WriteLine(t.value);
TestClass<string> t2 = new TestClass<string>();
t2.value = "123123";
Console.WriteLine(t2.value);
TestClass2<int,string,float,double,TestClass<int>,uint,short> t3 = new TestClass2<int,string,float,double,TestClass<int>,uint,short>();
Test2 tt = new Test2();
tt.TestFun<string>("123123");
}
}
}
C#中泛型T的应用的一些小知识
边栏推荐
- Personal blog system (with source code)
- These six ways to implement load balancing technology should not be missed
- The HMI Software memory is abnormal, resulting in a crash exit bug
- Export CSV file from neo4j diagram database
- 【RK2206】4. Mqtt example
- Fastjson解析JSON时乱序解决
- neo4j图数据库导出csv文件
- Who is the big winner? The Huawei cloud IOT innovation application development competition was successfully concluded!
- Discussion on mobx
- Lammps中常用的势函数和晶体库资源收集
猜你喜欢
随机推荐
Leetcode 1984. Différence minimale entre les notes des élèves (Oui, résolu)
Apply for software code signing certificate
Neo4j desktop database backup
C#中default的关键词用法
牛客网:关于第K个数的一些排序问题
FPGA入门实验-基于状态机实现多按键控制变速流水灯和跳变灯
阿里云22Q1状况汇总,你往哪走
Edge browser setting network speed limit
95后大厂程序员删库被判刑9个月
Unity UI slider component
paramiko和线程池Demo(快速批量操作服务器)
Smart PLC calls the same subroutine (FC) multiple times
Unity将Project升级至URP
Jerry's use of network diagram to replace LwIP library and WiFi library [chapter]
卡尔曼滤波(KF)无迹卡尔曼滤波(UKF)
官宣!博通将以610亿美元收购VMware,并承担80亿美元债务
Tips for writing code
moderlarts第二次培训笔记
Tidb single machine and cluster environment installation, single machine rapid experience
2022 Shandong Health Expo, dietotherapy and nourishing health exhibition, health management and precision medicine Exhibition







