Reconstructs a type from a string that was previously obtained via StringUtils.ToString(T data)
Syntax
Parameters
- input
- type
- 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.NET | Copy 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