I’m currently working with C++ and .NET 1.1 (Don’t ask…), and I’d like to check if an object is a CheckBox.
GetType seems the obvious choice, but for some reason I can’t get it to work like I want. Using GetType() on an instance of a CheckBox works fine, but trying to use Type::GetType("System.Windows.Forms.CheckBox") does not.
The following code will throw an exception on the second line, despite what should (in my mind at least) be a perfectly formatted string being fed to GetType(temp). If I replace temp with, for example, "System.Int32" instead, it works fine as well.
String* temp = (this->checkBox1->GetType())->ToString();
temp = (System::Type::GetType(temp))->ToString();
Why is this? =)
I can imagine several different ways to work around this of course, but it just bugs me that I can’t get this to work the way I think it should.
It looks like you’re using C++ with managed extensions. If so try the following