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: JIT compiler (will?) Inline it: Now, with these two examples (verbatim from the book): Example 1 Example 2 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: then the Similar code This is equivalent: For what can be inline: Note that the
public string SayHiTo (string name) {return "hi" + name ; } Public Zero Welcome () {var msg = SayHiTo ("Sergei"); }
Public Zero reception () {var msg = "Hi" + "Sergey"; }
// property of name to read only public string name {get; Private set; } // access: string val = Obj.Name;
string value = "default name"; If (Obj! = Null) val = Obj.Name;
private string name_; Public string get_Name () {return _name; } Private Zero Set_name (string value) {_name = value; }
string val = Obj.Name
string = valve = Obj.get_Name () which is
String val = obj._name .
string val = "default name"; If (Obj! = Null) val = Obj.Name;
string val = "default name"; If (Obj! = Null) val = Obj.get_Name ();
string val = "default name"; If (Obj! = Null) val = Obj._name;
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