genericsdemo.h
来自「C#高级编程第6版随书源代码 值得下载」· C头文件 代码 · 共 39 行
H
39 行
#pragma once
using namespace System::Collections::Generic;
ref class GenericsDemo
{
public:
static void UseGenerics()
{
List<int>^ intList = gcnew List<int>();
intList->Add(1);
intList->Add(2);
intList->Add(3);
}
};
generic <typename T>
where T : IComparable<T>
ref class MyGeneric
{
private:
List<T>^ list;
public:
MyGeneric()
{
list = gcnew List<T>();
}
void Add(T item)
{
list->Add(item);
}
void Sort()
{
list->Sort();
}
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?