i 试图制定一些法典。 i 面对代表。 一切都ok。 (见下文) 但似乎有一种警告:你坚持为什么有价值? 但下面的二部法典是ok。
namespace Delegates { class Program { static void Main(string[] args) {
HesapMak hesapla = new HesapMak(); hesapla.Calculator = new HesapMak.Hesap(hesapla.Sum); double sonuc = hesapla.Calculator(34, 2); Console.WriteLine("Toplama Sonucu:{0iii",sonuc.ToString()); Console.ReadKey(); iii iii class HesapMak { public double Sum(double s1, double s2) { return s1 + s2; iii public double Cikarma(double s1, double s2) { return s1 - s2; iii public double Multiply(double s1, double s2) { return s1 * s2; iii public double Divide(double s1, double s2) { return s1 / s2; iii public delegate double Hesap(double s1, double s2); public Hesap Calculator; ----< they want me assingn value iii
iii
namespace Delegates { class Program { static void Main(string[] args) { HesapMak hesapla = new HesapMak(); hesapla.Calculator = new HesapMak.Hesap(hesapla.Sum); double sonuc = hesapla.Calculator(34, 2); Console.WriteLine("Toplama Sonucu:{0iii",sonuc.ToString()); Console.ReadKey(); iii iii class HesapMak { public double Sum(double s1, double s2) { return s1 + s2; iii public double Cikarma(double s1, double s2) { return s1 - s2; iii public double Multiply(double s1, double s2) { return s1 * s2; iii public double Divide(double s1, double s2) { return s1 / s2; iii public delegate double Hesap(double s1, double s2); public Hesap Calculator=null; iii iii