You can use reflection to check if an object class overrides toString. Like this
if (obj.GetType().GetMethod("toString",
BindingFlags.Instance |
BindingFlags.Public |
BindingFlags.DeclaredOnly) != null)
{
}
- , - toString, .
MethodInfo pi = null;
Type t = obj.GetType(0;
while (t != typeof(object) && pi == null)
{
pi = t.GetMethod("toString",
BindingFlags.Instance |
BindingFlags.Public |
BindingFlags.DeclaredOnly);
t = t.BaseType;
}
if (pi != null)
{
}