📄 class1.cs
字号:
using System;
namespace DelegateSample
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
int type=Int32.Parse(Console.ReadLine());
int[] array=new int[10];
System.Random r=new Random();
for(int i=0;i<array.Length;i++)
{
array[i]=r.Next(1,100);
}
printArray(array);
SortDelegate.Comparator com;
if(type==0)
{
com=new DelegateSample.SortDelegate.Comparator(AES);
}
else
{
com=new DelegateSample.SortDelegate.Comparator(DESC);
}
if(com!=null)
{
SortDelegate.SortArray(array,com);
}
printArray(array);
Console.WriteLine(com.Method);
}
static bool AES(int i,int j)
{
return i<j;
}
static bool DESC(int i,int j)
{
return i>j;
}
static void printArray(int[] array)
{
foreach(int i in array)
{
Console.Write("{0}\t",i);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -