'GetType' Question

  • Thread starter Thread starter Razzerroo
  • Start date Start date
R

Razzerroo

Still on my quest to convert my company's VB.NET code to C#.

Here's the line I need to convert
VB.NET
System.Runtime.Remoting.RemotingServices.Connect(GetType(ISensor),
strURL))

where ISensor is a public Interface in a referenced class library (DLL)
and the strURL is a valid URI path.


C# Equivalent???
I've tried this in C#
RemotingServices.Connect(Type.GetType("ISensor"), strURL));
RemotingServices.Connect(Type.GetType("Sensors.ISensor"), strURL));
..
..
..
And as many other iterations as I could possibly think of using
namespaces and such. I'm stuck here since I can't figure out how to
get the type of the ISensor Interface to use with the "Connect" call.
C# seems to have no "Type GetType(object ob)" operator.

Thank you and Sincerely,

Kevin
 
Razzerroo said:
Still on my quest to convert my company's VB.NET code to C#.

Here's the line I need to convert
VB.NET
System.Runtime.Remoting.RemotingServices.Connect(GetType(ISensor),
strURL))

where ISensor is a public Interface in a referenced class library (DLL)
and the strURL is a valid URI path.


C# Equivalent???
I've tried this in C#
RemotingServices.Connect(Type.GetType("ISensor"), strURL));
RemotingServices.Connect(Type.GetType("Sensors.ISensor"), strURL));
.
.
.
And as many other iterations as I could possibly think of using
namespaces and such. I'm stuck here since I can't figure out how to
get the type of the ISensor Interface to use with the "Connect" call.
C# seems to have no "Type GetType(object ob)" operator.

I suspect you're after the "typeof" operator.
 
Back
Top