C#で var_dump

C#で var_dump するいい例がなかったので作った。

public static String var_dump(object obj)
{
    if (obj == null
        || obj is uint || obj is int
        || obj is ushort || obj is short
        || obj is byte || obj is byte
        || obj is float || obj is double || obj is bool
        || obj is UInt16 || obj is Int16
        || obj is UInt32 || obj is Int32
        || obj is UInt64 || obj is Int64
        ) 
    {
        return obj.ToString();
    }
    if (obj is string)
    {
        return "\"" + obj.ToString() + "\"";
    }
    string ret ;
    IEnumerable ienum = obj as IEnumerable;
    if (ienum != null)
    {
        ret = "[";
        foreach (object o in ienum)
        {
            ret += var_dump(o) + ",";
        }
        return ret + "]";
    }

    ret = "{";
    const BindingFlags FINDS_FLAG = BindingFlags.Public | BindingFlags.NonPublic |
            BindingFlags.Instance | BindingFlags.Static |
            BindingFlags.DeclaredOnly;
    FieldInfo[] infoArray = obj.GetType().GetFields(FINDS_FLAG);
    foreach (FieldInfo info in infoArray)
    {
        object o = info.GetValue(obj);
        ret += info.Name + ": " + var_dump( o ) + ",";
    }
    return ret + "}";
}