Question

I was hoping to get some clarity on the use of () before the call of a method (applies to class,struc, etc as well). Firstly I don't know what the action is called so having trouble in pinpointing where to start reading on it, and secondly if you have some explanation on why one would use this that would be great.

In the example below I am interested in the (TestClassRemoting) that is called in front of the Activator.Getobject(...) method.

Example

TestClassRemoting test = (TestClassRemoting)Activator.GetObject(someType,someString);

Now in the scripts, TestClassRemoting is just a class defined with a Text method that will print a string.

Was it helpful?

Solution

in languages like c# and java explicit type conversions are done by specifying the type the data should be converted to inside () brackets. so in your case the object returned by the Activator.GetObject is converted to type TestClassRemoting.

find more info here,

http://en.wikipedia.org/wiki/Type_conversion

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top