1

I have a string array which have different types of symbols. I divided it into separate elements, and now one of them is my 2.6. I just want him to convert, but gives me an error, tried different methods and written me:

Input string was not in a correct format.

string s = Console.ReadLine(); // Input "Apr\2.6\7\300";
string[] array = s.Split('\\'); // array is with separeted: Apr  2.6  7  300

double[] num = new double[3];  
num[0] = double.Parse(intArray[1]); // Help me for this Convert ! :)
1
  • 1
    intArray is not declared on your example. is it array? Commented Aug 16, 2015 at 21:56

1 Answer 1

2

It seems that your current culture has a different decimal separator.

You can specify the invariant culture for the parsing, which has a period as decimal separator:

num[0] = double.Parse(array[1], CultureInfo.InvariantCulture);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.