syntax - In C#, why you can set a property to its self -
this question has answer here:
accidentally created bug in work. cause of bug snippet of c# code
public classa{ public string aproperty { { return aproperty; } set { aproperty = value; } } } you can build that, , running without exceptions. create infinite loop. example, while setting aproperty, tries assign value self.
anyone knows why in c# compiler allow syntax?
because c# compiler team didn't decide make exact case illegal. possibly because didn't consider benefits of implementing greater costs.
it's comes trivial amount of testing; it's not subtle bug, , it's developers learn if bitten few times.
Comments
Post a Comment