当前位置:网站首页>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边栏推荐
猜你喜欢

One article solves all search backtracking problems of Jianzhi offer

Unity technical manual - interference / noise sub module

Deep learning network model

【深入理解TcaplusDB技术】TcaplusDB导入数据

Good news | Haitai Fangyuan has passed the cmmi-3 qualification certification, and its R & D capability has been internationally recognized

SDN系统方法 | 10. SDN的未来

安装spark + 用命令运行scala相关项目 + crontab定时执行

Slam visuel Leçon 14 leçon 9 filtre Kalman

IVX sailing

Sword finger offer double pointer
随机推荐
Video production material website arrangement
[tips] how to quickly start a new position for a new software testing engineer
【深入理解TcaplusDB技术】一键安装Tmonitor后台
什么是泛型以及在集合中泛型的使用[通俗易懂]
Getting started with kotlin (20) several common dialog boxes
IET出席2022世界科技社团发展与治理论坛 为构建国际科技共同体献言献策
Wechat applet reports an error: request:fail URL not in domain list
Redis trend - NVM memory
Android物联网应用程序开发(智慧园区)—— 图片预览界面
实际开户复杂吗?在线开户安全么?
Using QT to make a beautiful login interface box
Deep learning network model
微服务介绍
近来开发的一款简单易用的图可视化工具
User scheduling problem
篇4:win10安装MingW64
SQL Server实时备份库要求
What is an operator?
JSP page running but displaying source code
存在重复元素III[利用排序后的有序性进行剪枝]