System.ComponentModel.TypeConverter.ConvertToInvariantString C# (CSharp) Method

ConvertToInvariantString() public method

public ConvertToInvariantString ( ITypeDescriptorContext context, object value ) : string
context ITypeDescriptorContext
value object
return string
        public string ConvertToInvariantString(ITypeDescriptorContext context, object value) {
            return ConvertToString(context, CultureInfo.InvariantCulture, value);
        }

Same methods

TypeConverter::ConvertToInvariantString ( object value ) : string

Usage Example

Example #1
0
    //</snippet2>

    // The following code example demonstrates how to use the
    // ConvertToInvariantString and ConvertToString methods.
    // This example is designed to be used with Windows Forms.
    // Paste this code into a form and call the ShowFontStringConversion
    // method when handling the form's Paint event, passing e
    // as PaintEventArgs.
    //<snippet3>
    private void ShowFontStringConversion(PaintEventArgs e)
    {
        // Create the FontConverter.
        System.ComponentModel.TypeConverter converter =
            System.ComponentModel.TypeDescriptor.GetConverter(typeof(Font));

        Font font1 = (Font)converter.ConvertFromString("Arial, 12pt");

        string fontName1 = converter.ConvertToInvariantString(font1);
        string fontName2 = converter.ConvertToString(font1);

        e.Graphics.DrawString(fontName1, font1, Brushes.Red, 10, 10);
        e.Graphics.DrawString(fontName2, font1, Brushes.Blue, 10, 30);
    }
All Usage Examples Of System.ComponentModel.TypeConverter::ConvertToInvariantString