CSharpTest.Net
ToString(Object) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > StringUtils Class > ToString Method : ToString(Object) Method

value

Glossary Item Box

Converts primitives to strings so that they can be reconstituted via TryParse

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function ToString( _
   ByVal value As Object _
) As String
C# 
public static string ToString( 
   object value
)

Parameters

value

Example

Library/Library.Test/TestStringUtils.cs

C#Copy Code
Assert.AreEqual("5.1", StringUtils.ToString<double>(5.1));
Assert.AreEqual("5.1", StringUtils.ToString((object)new Version(5, 1)));

int ival;
object oval;

Assert.IsTrue(StringUtils.TryParse("1", out ival));
Assert.AreEqual(1, ival);

Assert.IsTrue(StringUtils.TryParse("1", typeof(int), out oval));
Assert.AreEqual(1, oval);
VB.NETCopy Code
Assert.AreEqual("5.1", StringUtils.ToString(Of Double)(5.1))
Assert.AreEqual("5.1", StringUtils.ToString(DirectCast(New Version(5, 1), Object)))

Dim ival As Integer
Dim oval As Object

Assert.IsTrue(StringUtils.TryParse("1", ival))
Assert.AreEqual(1, ival)

Assert.IsTrue(StringUtils.TryParse("1", GetType(Integer), oval))
Assert.AreEqual(1, oval)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys