代理有什么用?可以不用代理么?
在网上看到如下代码
using System;
using System.Collections.Generic;
using System.Text;
using Common;
namespace ConsoleApplication8
{
public delegate bool CompareDelegate(int a, int b);
public class MyCompare
{
public static bool CompareMethod(int x , int y)
{
bool result = x > y ? true : false;
return result;
}
}
class Program
{
static void Main(string[] args)
{
CompareDelegate myDelegate = new CompareDelegate(MyCompare.CompareMethod);
int a = 10;
int b = 15;
bool isBigger = myDelegate(a, b);
Console.WriteLine(" a > b ?: " + isBigger);
Console.Read();
}
}
}
如果这样我倒不如直接
MyCompare myCompare= new MyCompare();
myCompare.CompareMethod(a,b);
这样不更简单么?