Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the (type) in (type)objectname.var

Tags:

c#

casting

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();
}
like image 841
pghtech Avatar asked Dec 07 '22 02:12

pghtech


1 Answers

It is casting, it is trying to cast variablename into type (type) at runtime

like image 154
Iain Ward Avatar answered Dec 29 '22 07:12

Iain Ward