Using "this" in getters/setters in C# -
Using "this" in getters/setters in C# -
short , sweetness (hopefully), there specific reason not utilize this
keyword when writing getters , setters in c#? know typical format, , 1 i've used, is:
public void setday(int _day) { day = _day; } public int getday() { homecoming day; }
recently though, i've been learning java, , in several of books i've been using i've seen written instead this:
public void setday(int _day) { this.day = _day; } public int getday() { homecoming this.day; }
so basically, there reason avoid doing same way in c#? cause problems or errors, or valid approach , matter of personal preference. i'm wondering because, while know this
in c# understood, explicitly using this
keyword seems aid in eliminating bit ambiguity, thing.
thank you!
there's not much really. can it, , can avoid it. think it's quite obvious when you're in getter/setter you're talking object you're in, i've never used there.
also, seems resharper suggest it's redundant, , grayness out.
if find of utilize (readability wise), means, utilize it. otherwise, it'll save 5 keystrokes (about second?) every time implement getter hand ... :)
c# this getter-setter
Comments
Post a Comment