Here you can find a generic Type conversion snippet for C# and VB.NET.
Sample C#
public static T GenericConvert<T, X>(X value) where X : IConvertible { return (T)Convert.ChangeType(value, typeof(T)); }
Sample VB.NET
Public Shared Function GenericConvert(Of T, X As IConvertible)(value As X) As T Return DirectCast(Convert.ChangeType(value, GetType(T)), T) End Function
RT @CodeSnippetsNET: Generic Type Conversion snippet for C# and #VB .NET http://t.co/795oKgNRyB #programming #dotnet #csharp #visualstudio …
RT @CodeSnippetsNET: Generic Type Conversion snippet for C# and #VB .NET http://t.co/795oKgNRyB #programming #dotnet #csharp #visualstudio …
RT @CodeSnippetsNET: Generic Type Conversion snippet for C# and #VB .NET http://t.co/795oKgNRyB #programming #dotnet #csharp #visualstudio …