Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

Commented Unassigned: Distance.Parse is inconsistant with invalid input [24937]

$
0
0
Distance.Parse throws an exception when a number with an unrecognized unit is entered:

```
Distance.Parse("3 this should not be valid");
```

This is fine, but if the number is removed:

```
Distance.Parse("this should not be valid");
```

Then the function returns a Distance object set to "0 ft" and IsInvalid=false.

Invalid text without a number should throw an exception.
Comments: ** Comment from web user: RayHarwood **

For VB, this is actually "technically consistent". In the first case, it parses a 3 and discards the rest. In the second case, it cannot find any valid numerical at the beginning, so it throws an error.

I recommend using the alternative TryParse instead.


Viewing all articles
Browse latest Browse all 3973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>