System.Enum.InternalFormat C# (CSharp) Метод

InternalFormat() приватный статический Метод

private static InternalFormat ( Type eT, Object value ) : String
eT Type
value Object
Результат String
        private static String InternalFormat(Type eT, Object value)
        {
            if (!eT.IsDefined(typeof(System.FlagsAttribute), false)) // Not marked with Flags attribute
            {
                // Try to see if its one of the enum values, then we return a String back else the value
                String retval = InternalGetValueAsString(eT, value);
                if (retval == null)
                    return value.ToString();
                else
                    return retval;
            }
            else // These are flags OR'ed together (We treat everything as unsigned types)
            {
                return InternalFlagsFormat(eT, value);

            }
        }

Usage Example

Пример #1
0
 public override String ToString()
 {
     // Returns the value in a human readable format.  For PASCAL style enums who's value maps directly the name of the field is returned.
     // For PASCAL style enums who's values do not map directly the decimal value of the field is returned.
     // For BitFlags (indicated by the Flags custom attribute): If for each bit that is set in the value there is a corresponding constant
     //(a pure power of 2), then the  OR string (ie "Red | Yellow") is returned. Otherwise, if the value is zero or if you can't create a string that consists of
     // pure powers of 2 OR-ed together, you return a hex value
     return(Enum.InternalFormat((RuntimeType)GetType(), GetValue()));
 }