Export (0) Print
Expand All

UInt64.ToString Method (String, IFormatProvider)

Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.

This method is not CLS-compliant.  

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public:
virtual String^ ToString (
	String^ format, 
	IFormatProvider^ provider
) sealed
public final String ToString (
	String format, 
	IFormatProvider provider
)
public final function ToString (
	format : String, 
	provider : IFormatProvider
) : String

Parameters

format

A format specification.

provider

An IFormatProvider that supplies culture-specific formatting information about this instance.

Return Value

The string representation of the value of this instance as specified by format and provider.

Exception typeCondition

FormatException

The format parameter is invalid.

If format is a null reference (Nothing in Visual Basic) or an empty string (""), the return value for this instance is formatted with the general format specifier ("G").

The provider parameter is an IFormatProvider that obtains a NumberFormatInfo. The NumberFormatInfo provides culture-specific format information about this instance. If provider is a null reference (Nothing in Visual Basic), the return value for this instance is formatted with the NumberFormatInfo for the current culture.

The following example demonstrates the ToString method.

   public ref class Temperature: public IFormattable
   {
   public:
      /// <summary>
      /// IFormattable.ToString implementation.
      /// </summary>
      virtual String^ ToString( String^ format, IFormatProvider^ provider )
      {
         if ( format != nullptr && format == "F" )
         {
            return String::Format( "{0}'F", this->Value.ToString() );
         }

         return m_value.ToString( format, provider );
      }

   protected:
      // The value holder
      UInt64 m_value;

   public:
      property UInt64 Value 
      {
         UInt64 get()
         {
            return m_value;
         }
         void set( UInt64 value )
         {
            m_value = value;
         }
      }
   };
}

public class Temperature implements IFormattable
{
    /// <summary>
    /// IFormattable.ToString implementation.
    /// </summary>
    public String ToString(String format, IFormatProvider provider)
    {
        if (format != null && format.Equals("F")) {
            return String.Format("{0}'F",
                ((Int64)this.get_Value()).ToString());
        }
        return ((Int64)mValue).ToString(format, provider);
    } //ToString

    // The value holder
    protected long mValue;

    /** @property 
     */
    public long get_Value()
    {
        return mValue;
    } //get_Value

    /** @property 
     */
    public void set_Value(long value)
    {
        mValue = value;
    } //set_Value
} //Temperature

public class Temperature implements IFormattable {
    /// <summary>
    /// IFormattable.ToString implementation.
    /// </summary>
    public function ToString(format : String, provider : IFormatProvider) : String {
        if( format != null && format.Equals("F") ) {
            return String.Format("{0}'F", m_value.ToString());
        }

        return m_value.ToString(format, provider);
    }

    // The value holder
    protected var m_value : ulong;

    public function get Value() : ulong {
        return m_value;
            }
            
            public function set Value(value : ulong) {                        
        m_value = value;
    }
}

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft