当前位置:网站首页>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
边栏推荐
- Uncover ges super large scale graph computing engine hyg: Graph Segmentation
- SDN系统方法 | 10. SDN的未来
- Qt使用SQLITE数据库
- . How to exit net worker service gracefully
- What is an operator?
- CentOS7 安装 Redis 7.0.2
- Meaning of% in C language
- Install spark + run Scala related projects with commands + crontab scheduled execution
- How to delay the delay function
- How to open a stock account is it safe to open an account
猜你喜欢
【深入理解TcaplusDB技術】TcaplusDB業務數據備份
A simple and easy-to-use graph visualization tool developed recently
Kotlin of Android cultivation manual - several ways to write a custom view
【深入理解TcaplusDB技术】TcaplusDB机型
SQL Server实时备份库要求
沁恒CH583 USB 自定义HID调试记录
[in depth understanding of tcapulusdb technology] tcapulusdb business data backup
【深入理解TcaplusDB技术】如何实现Tmonitor单机安装
General message publishing and subscription in observer mode
Slam visuel Leçon 14 leçon 9 filtre Kalman
随机推荐
Expressing integers by the sum of consecutive natural numbers
new TypeReference用法 fastjson[通俗易懂]
Recursion and divide and conquer
Deep learning network model
Qt产生指定范围内随机数(随机字符串)
158_模型_Power BI 使用 DAX + SVG 打通制作商业图表几乎所有可能
Qt使用SQLITE数据库
jvm问题复盘
The performance of the server's four channel memory is improved. How about the performance of the four channel memory
20 provinces and cities announce the road map of the meta universe
Is it convenient to open a stock account? Is online account opening safe?
ASP.NET超市便利店在线购物商城源码,针对周边配送系统
Android Internet of things application development (smart Park) - picture preview interface
将Graph Explorer搬上JupyterLab:使用GES4Jupyter连接GES并进行图探索
【深入理解TcaplusDB技术】Tmonitor后台一键安装
How to open a stock account is it safe to open an account
One article solves all search backtracking problems of Jianzhi offer
Using QT to make a beautiful login interface box
【深入理解TcaplusDB技术】单据受理之建表审批
中断操作:AbortController学习笔记