getter setter - In C# How to call Set method without a value -


i have property , set method something, want call set method without value, how can that?

for example following property set method:

private int mynum; public string mynumber {     { return mynum };     set {           randon rnd = new random();           mynum = rnd.next(1,13);         } } 

you're ignoring value anyway, can call value. however, goes against expectation can reasonably have while calling setter.

so put logic method describes intent:

public int mynumber { get; private set; }  public void setrandomnumber() {     random rnd = new random();     mynumber = rnd.next(1,13); } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -