Here you need to consider a lot of things, but first we will take up the simplest ones:
What is the syntax (type)expression?
Well, in its main form casting is considered. You apply an expression from one type to another. What is it.
However, what exactly is happening depends on the type and many other things.
- , , , . , , , , .
, . , .
, , .
:
int a = (int)byteValue;
, , object , .
:
object o = intValue;
int i = (int)o;
. , "someValueType" - , IDisposable:
IDisposable disp = (IDisposable)someValueType;
, - .
-, , , , , .
, (. ).
:
string s = (string)myObjectThatCanBeConvertedToAString;
, , .
:
IDisposable disp = (IDisposable)someDisposableObject;