Extensions.To |
To the invariant string.
Namespace: Gamanet.C4.SimpleInterfaces
Assembly: Gamanet.C4.SimpleInterfaces (in Gamanet.C4.SimpleInterfaces.dll) Version: 2026.0.0.242
Syntax
C#
public static string ToInvariantString( this Object obj )
Parameters
- obj Object
- The object.
Return Value
Stringstirng
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type Object. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Example
The following example illustrates how to get invariant string from any object
C#
using System; using System.Collections.Generic; using Gamanet.C4.SimpleInterfaces; public static class IsNullOrEmptyString { static void Main() { // write to console invariant string of different objects Console.WriteLine("some text...".ToInvariantString()); Console.WriteLine((-1).ToInvariantString()); Console.WriteLine(1.55555.ToInvariantString()); var person = new SimplePerson(Guid.NewGuid(), "Pers", Guid.Empty, Guid.Empty); Console.WriteLine(person.ToInvariantString()); Console.WriteLine(new Dictionary<string, object>{ { "Person", person } }.ToInvariantString()); Console.WriteLine(new Finger().ToInvariantString()); // The example displays the following output: some text... -1 1.55555 Gamanet.C4.SimpleInterfaces.SimplePerson System.Collections.Generic.Dictionary`2[System.String,System.Object] Gamanet.C4.SimpleInterfaces.Finger } }
See Also