Dim objCar As Car
objCar = New Car
Console.WriteLine("{0}", objCar.GetType.ToString())
Returns this
Objects.Car
Can I change the code slightly, without using text functions, to just return the following?
Car
Dim objCar As Car
objCar = New Car
Console.WriteLine("{0}", objCar.GetType.ToString())
Returns this
Objects.Car
Can I change the code slightly, without using text functions, to just return the following?
Car
Did you Try this.?
Dim objCar As car
objCar = New car
MsgBox(objCar.GetType.Name)
Why not just override the ToString
method on your Car
class?
public class Car
{
public Car() {}
public override string ToString()
{
return "Car";
}
}
That way you can return whatever you want to return out of it without having to use GetType
.