What is value
keyword here and how is it assigning the value to _num
? I'm pretty confused, please give the description for the following code.
private int _num;
public int num
{
get
{
return _num;
}
set
{
_num=value;
}
}
public void button1_click(object sender,EventArgs e)
{
num = numericupdown.Value;
}
In the context of a property setter, the value
keyword represents the value being assigned to the property. It's actually an implicit parameter of the set
accessor, as if it was declared like this:
private int _num
public int num
{
get
{
return _num;
}
set(int value)
{
_num=value;
}
}
Property accessors are actually methods equivalent to those:
public int get_num()
{
return _num;
}
public void set_num(int value)
{
_num = value;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With