Re: Type convertsion from string



Have you tried Convert.ChangeType?

Jon,

thank you. I changed second line to

p.SetValue(entityTmp, Convert.ChangeType(e.Value, p.PropertyType), null);

and this works.

When user enters letters to numeric cell, this line causes Exception.
How to check that conversion can be performed ?
Should I use try catch to catch this exception or is it possible to
determine conversion error before raising exception ?

Andrus.


.



Relevant Pages

  • Re: Python from Wise Guys Viewpoint
    ... The data conversion instructions were ... > not protected from causing an Operand Error, ... the conversion caused an exception because ... the Ariane-5 had a tilt angle beyond what the SRI was designed for. ...
    (comp.lang.python)
  • Re: Python from Wise Guys Viewpoint
    ... The data conversion instructions were ... > not protected from causing an Operand Error, ... the conversion caused an exception because ... the Ariane-5 had a tilt angle beyond what the SRI was designed for. ...
    (comp.lang.lisp)
  • Data source controls and parameter type conversion
    ... Exception I got: ... Since String and Int32 are incompatible types, ... perform conversion from String to Int32 in the first place? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: I Need an IsNumeric Method
    ... public bool IsNumeric ... //Try a double conversion. ... try to convert and catch the exception ... > o Don't forget that .5 is generally considered okay, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: complex arithmetics
    ... That doesn't imply that l = int(r) is a 64-bit result, nor does it imply that l = intis a 64-bit result. ... All type conversion functions return default kind, ... The cmplx>>> fits the pattern <<< rather than being the exception. ... intrinsics, and, therefore, perhaps surprising. ...
    (comp.lang.fortran)