I am going through a book on C# and have come across something that I can't seem to look up, because I don't know what it is called, or trying to search for something by description.
Could some explain to me what is going on, or the meaning behind the (type)
that comes before a reference to an object as in (int)objectname.variablename
?
It seems like casting to me.
EDIT: Since most of you are going off 'My' reference to casting when I am only guessing, and needed more code, I am including the code that I am reviewing that has brought on this question. I am questioning the (int) in the (int)numericupDown1.Value;
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
dinnerParty.NumberOfPeople = (int)numericUpDown1.Value;
DisplayDinnerPartyCost();
}
It is casting, it is trying to cast variablename into type (type) at runtime
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