I am reading and it talks about method inlining .
I understand the theory, but I do not think how it will work based on 2 examples in the book. The book says:
Meaning of the function is the option of the function of the body of the function for the call.
is fair enough, so if I have a method, and its call:
public string SayHiTo (string name) {return "hi" + name ; } Public Zero Welcome () {var msg = SayHiTo ("Sergei"); }
JIT compiler (will?) Inline it:
Public Zero reception () {var msg = "Hi" + "Sergey"; }
Now, with these two examples (verbatim from the book):
Example 1
// property of name to read only public string name {get; Private set; } // access: string val = Obj.Name;
Example 2
string value = "default name"; If (Obj! = Null) val = Obj.Name;
The code is mentioned in this book but how can it be extended inline form. How will the JIT compiler write these 2 instances?
The syntax for the automatic property field backed properties is Chinese.
The syntax for the property setter and / or the poor method is Chinese.
Therefore the code you gave is more or less equivalent:
private string name_; Public string get_Name () {return _name; } Private Zero Set_name (string value) {_name = value; }
then the
string val = Obj.Name
string = valve = Obj.get_Name () which is
String val = obj._name .
Similar code
string val = "default name"; If (Obj! = Null) val = Obj.Name;
This is equivalent:
string val = "default name"; If (Obj! = Null) val = Obj.get_Name ();
For what can be inline:
string val = "default name"; If (Obj! = Null) val = Obj._name;
Note that the
private and
public apply to the compilation, not to execute, so the fact that the banking field is private Invalid code outside the
Obj._name question, the equivalent code produced by inlineing is allowed.
Comments
Post a Comment