Syntax: The use of round brackets () in front of a method call

你。 提交于 2020-01-22 02:53:07

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/23589995/syntax-the-use-of-round-brackets-in-front-of-a-method-call

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!