Welcome! and rules
Joel on Software
Easy Type Conversion
I'm looking for an easier way to do this. Using the System.Convert.ChangeType function requires a Type object as one of the parameters. I am unable to find a good source for that object. Currently I have to dimension an instance of the object and then call the .GetType method... There has got to be a better way!
How about using the static Type.GetType("TypeName") method?
For basic conversions you can use Convert.ToXXX() methods. Hope I understood properly.
Probably, you should use "is" and "as" C# operators?
Mike thanks. "Type.GetType("TypeName") " was what I was looking for. I never thought of that one.... Does anyone else think its strange that the GetType method of the Type object (static it may be) doesnt return the Type of the Type object like GetType does everywhere else? :) funky, although I guess it makes sense.....
You know, I thought about it. That DOESNT make sense at all. Methods of the Object class shouldnt be overloaded to add additional functionality. It just confuses the issue. I, and I think many others, look for functionality by browsing the .[LIST 'O' COMMANDS] popup and the object browser. If that command had been listed as something else I think I would have seen it. As it is, my mind is already trained to overlook stuff that looks like basic object stuff...
If you know the type at compile time, then using the C# typeof operator is even better (better performance & some compiler validation). Confusingly enough the VB equivalent is the GetType operator, not the TypeOf operator which does something completely different.
[You know, I thought about it. That DOESNT make sense at all. Methods of the Object class shouldnt be overloaded to add additional functionality]
Where does it says that ToString() returns the class name?
Joao Paulo Carreiro
I guess the point of my gripe is that the .GetType method has an established functionality. The static version off the Type class changes that behavior. In contrast, the ToString method DOESNT behave so consistantly so it is less of a shock when its behavior changes.
Fog Creek Home