本人在学习c#中,希望大家指导。能每条语句都解释一下吗?
using System;
class MyClass
{
public MyClass() {
Console.WriteLine("Constructor");
}
public MyClass(int value) {
MyField = value;
Console.WriteLine("Constructor");
}
~MyClass() {
Console.WriteLine("Destructor");
}
public const int MyConstant = 12;
public int MyField = 34;
public void MyMethod(){
Console.WriteLine("MyClass.MyMethod");
}
public int MyProperty {
get {
return MyField;
}
set {
MyField = value;
}
}
public int this[int index] {
get {
return 0;
}
set {
Console.WriteLine("this[{0}] was set to {1}", index, value);
}
}
public event EventHandler MyEvent;
public static MyClass operator+(MyClass a, MyClass b) {
return new MyClass(a.MyField + b.MyField);
}
internal class MyNestedClass
{}
}