📄 genericsdemo.h
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -