I am writing an interop between a php service and our crm. One of the things I need to do is make sure that simple types get converted ToString() for use later in a json converter.
I am not sure even what the name is for 'simple types' but it can be defined like this... "an object that represents a low level variable type, containing a single value, not a class or anything with executable functions etc"
I've found that int, string, bool, double, and surprisingly enum will ToString() with pretty predictable results.
int x = 0;
bool y = true;
double z = 1.59 // money
CustomEnum theEnum = CustomEnum.somevalue;
List<int> iList = new List<int>();
MyClass theClass = new MyClass();
So you want to check whether a type has a overridden
ToString method? Why not just check whether the value returned by
ToString is equal to the value returned by the default implementation of
From here, we know the default implementation of
So, we can use this to check whether an object has overridden the
bool toStringOverridden = someObject.GetType().ToString() != someObject.ToString();