The main constructor to initialize the object. It is divided into static (static) and the example (instance) constructor of two categories. We should all understand that if the class to write constructor, only that the default under the constructor's role in the category, as well as to retain the default constructor. In fact, I was wrong. Be truer to say that: in the category, as well as to retain empty constructor parameters. We have to write a Class A, the following code: view plaincopy to clipboardprint?
public class A
(
public int Number; / / digital
public string Word; / / text
)
/ / Test at the instance of class
public class Test
(
static void Main ()
(
A a = new A (); / / instantiate, A () is the Class A default constructor
Console.WriteLine ( "Number = (0)" nWord = (1) ", a.Number, a.Word);
Console.read ();
)
)
As a result of output:
Number = 0
Word = |