UserInfoES userInfo_1=default;
UserInfoES userInfo_2=null;
Declare a reference type empty variable, we use=null or=default? What's the difference?
CodePudding user response:
Are generally not null, conveniently used accustomed to
CodePudding user response:
The compiler can tell you, could you, never ignore the error, is on the development environment, so need not worry too much,CodePudding user response:
Used to null, the default nowCodePudding user response:
General not statement,Variable declaration had better use nearby principle,
CodePudding user response:
They had no problems, but you declare variables are generally to be used, then in the new place to useCodePudding user response:
Use nullCodePudding user response:
See good personal habits,I tend to be null, after all didn't default
CodePudding user response:
I generally don't write, I will empty,I intentionally empty, because the compiler will have a hint, at least can remind me at least check over all branches and ensure that there is nothing wrong with branching logic are, to catch up on,
You to write in c #, must be a subsequent initialization, also someone with, so he is null or a default actually doesn't matter, just let the compiler, but our own logic to ensure that the branch must conform to the reservation, so simple I don't want to fool the compiler, I prefer to write code
CodePudding user response: