c# - Is "get" called when we call "set" for a property -
This may be a trivial question, but I have been really confused about it. I have an asset with some argument in it.
Private SomeObject _someProperty; Public SomeObject SomeProperty {Here are some checks, return _supportery; } Set {_someProperty = value; }} What happens now when I am going to assign something to this property.
SomeProperty = new SomeClass (); What I was thinking here would be said to get here. This term can be said that like get someProperty and set that property but what I have seen is that it is not called received Only called seater (correct me if I am wrong here). I want to know that if is found is not called, then what is the reason for it?
No, when setting the property, the balloon of a property is not called, as easily Can be displayed:
Fixed class program {static zero main (string [] arg) {Foo foo = new Foo}; Foo.Number = 7; }} Public class Foo {Private entity number; Receive public integer number {console {console} WrightLine (in "Recipient"); Return to this number; } Set {Console.WriteLine ("in the setter"); This.number = value; }}} Output:
in setter
Comments
Post a Comment