当前位置:网站首页>C#泛型类案例
C#泛型类案例
2022-06-25 18:12:00 【济南医疗小程序状元】
泛型基础入门类
public class Program
{
public class Static<T> //定义的泛型类
{
int pos;
T[] data = new T[100]; //定义泛型数组
public void Push(T obj) //入栈操作
{
data[pos++] = obj;
}
public T Pop(T obj) //出栈操作
{
return data[--pos];
}
}
static void Main(string[] args)
{
var stack = new Stack<int>();
//也可写成:Stack<int> stack=new Stack<int>();
stack.Push(5);
stack.Push(10);
stack.Push(11);
stack.Push(1);
int x = stack.Pop(); //x=5
int y = stack.Pop(); //y=10
int a = stack.Pop(); //a=11
int b = stack.Pop(); //b=1
Console.WriteLine("{0},{1},{2边栏推荐
- Find the longest substring length satisfying the condition
- 1. Understanding of norm
- 【 NLP 】 in this year's English college entrance examination, CMU delivered 134 high scores with reconstruction pre training, significantly surpassing gpt3
- Deep understanding of ELF files
- Is it safe for a securities company to open an account with the lowest handling fee among the top ten
- Is it convenient to open a stock account? Is online account opening safe?
- 华为云SRE确定性运维专刊(第一期)
- ASP.NET超市便利店在线购物商城源码,针对周边配送系统
- SDN system method | 10 The future of SDN
- Computing architecture of microblog comments
猜你喜欢
随机推荐
One article solves all search backtracking problems of Jianzhi offer
微信小程序报错:request:fail url not in domain list
深度学习网路模型
SDN system method | 10 The future of SDN
Sword finger offer double pointer
移动端异构运算技术 - GPU OpenCL 编程(基础篇)
【深入理解TcaplusDB技术】单据受理之创建业务指南
Centos7 installing redis 7.0.2
SDN系统方法 | 10. SDN的未来
力扣每日一题-第27天-561.数组拆分Ⅰ
Is the actual account opening complicated? Is online account opening safe?
. How to exit net worker service gracefully
IET出席2022世界科技社团发展与治理论坛 为构建国际科技共同体献言献策
实际开户复杂吗?在线开户安全么?
20 provinces and cities announce the road map of the meta universe
十大券商的排名是?手机开户安全么?
【深入理解TcaplusDB技术】Tmonitor系统升级
篇6:CLion:Toolchains are not configured Configure Disable profile
New characteristics of cultural consumption in the era of digital economy
【flutter 页面跳转后退如何刷新?】




![存在重复元素III[利用排序后的有序性进行剪枝]](/img/26/5c3632a64945ea3409f8240ef5b18a.png)




