Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. public class MyClass
  2. {
  3. public BigInteger Value { get; set; }
  4.  
  5. public Dictionary<BigInteger, string> Dictionary { get; set; } = new Dictionary<BigInteger, string>();
  6. }
  7.  
  8. public class BigIntegerConverter : TypeConverter
  9. {
  10. public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
  11. {
  12. if(value is string)
  13. {
  14. return BigInteger.Parse((string)value);
  15. }
  16. return base.ConvertFrom(context, culture, value);
  17. }
  18. public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
  19. {
  20. if(sourceType == typeof(string))
  21. {
  22. return true;
  23. }
  24. return base.CanConvertFrom(context, sourceType);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement