Home > Net >  Solving, new object code directly written in c # class why can be executed directly
Solving, new object code directly written in c # class why can be executed directly

Time:09-30

Public class A {
B B=new B ();

}

Public class B {
.
}

B B=new B (); Why was not this sentence in the method, in the new why can initialize B?

CodePudding user response:

Member variables can be directly in the definition of initialization, when in fact or in the constructor, the compiler will the initialization code in the constructor

CodePudding user response:

C # is not C, so to write

CodePudding user response:

This need not struggle, language designers think can so, can such,

If language designers think you must be initialized in structure, then you can initialize in structure,

This why does not exist, such as pyton designers think you must be indented to run, so can only in this way,
Delphi designers think assignment must be written in XXX:=1, have to take: number, so we can only so
  •  Tags:  
  • C#
  • Related