replace v6 with experimental v7 code

This commit is contained in:
stax76
2023-10-24 11:17:45 +02:00
parent fb27bb8727
commit 5706d7b66d
212 changed files with 15014 additions and 12173 deletions

View File

@@ -0,0 +1,33 @@

using System.ComponentModel;
namespace HandyControl.Tools.Extension
{
public static class StringExtension
{
public static T Value<T>(this string input)
{
try
{
return (T) TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(input);
}
catch
{
return default;
}
}
public static object Value(this string input, Type type)
{
try
{
return TypeDescriptor.GetConverter(type).ConvertFromString(input);
}
catch
{
return null;
}
}
}
}