Thread: IFormatProvider.GetFormat

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    IFormatProvider.GetFormat

    Hello everyone,


    I debugged the sample carefully. But one question I can not find from MSDN, who calls method IFormatProvider.GetFormat of class AnyRadix? When we call String.Format, this function is called?

    http://msdn.microsoft.com/en-us/libr...at(VS.80).aspx


    thanks in advance,
    George

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    The System.Diagnostics namespace has a class called StackTrace. Create an instance of this object inside your functions and print the ToString representation of that object, to get a stack trace.

    Example:

    Code:
        // This method returns an object that implements ICustomFormatter 
        // to do the formatting. 
        public object GetFormat(Type argType)
        {
            StackTrace st = new StackTrace();
    
            System.Windows.Forms.MessageBox.Show( st.ToString() );
            
            // Here, the same object (this) is returned, but it would 
            // be possible to return an object of a different type.
            if (argType == typeof(ICustomFormatter))
                return this;
            else
                return null;
        }
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed