Code :
Decimal kilometro = Decimal.TryParse(myRow[0].ToString(), out decimal 0);
some arguments are not valid?
TryParse(String, NumberStyles, IFormatProvider, Decimal) Converts the string representation of a number to its Decimal equivalent using the specified style and culture-specific format. A return value indicates whether the conversion succeeded or failed.
TryParse is . NET C# method that allows you to try and parse a string into a specified type. It returns a boolean value indicating whether the conversion was successful or not. If conversion succeeded, the method will return true and the converted value will be assigned to the output parameter.
TryParse(String, Int32) Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded.
In C#, Char. TryParse() is Char class method which is used to convert the value from given string to its equivalent Unicode character.
out decimal 0
is not a valid parameter - 0
is not a valid variable name.
decimal output;
kilometro = decimal.TryParse(myRow[0].ToString(), out output);
By the way, the return value will be a bool
- from the name of the variable, your code should probably be:
if(decimal.TryParse(myRow[0].ToString(), out kilometro))
{
// success - can use kilometro
}
Since you want to return kilometro
, you can do:
decimal kilometro = 0.0; // Not strictly required, as the default value is 0.0
decimal.TryParse(myRow[0].ToString(), out kilometro);
return kilometro;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With