0

Hello I am new to C# and trying to learn. I require some help if anybody is able to help I would really appreciate it.

So I am making a program that takes lottery numbers from a website and compares them with the user imputed numbers. I have managed to this but the problem I have is that I get the numbers as a string like this 384826453514 then I compare the string with he user input, so as you can tell if I enter 3 8 4 6 5 1 its says win!

How can I parse or change that string to an array of Integers that have two values like this int[38][48][26][45][35][14] (I know this is not an actually array).

Any help would be very much appreciated even to point me in the right direction.

4
  • 6
    how do you know if 384826... is 38, 48, 26 ... or 38, 4, 8, 2, 6 ... ? Commented Jul 19, 2015 at 20:05
  • 1
    Should it really say "win" if the numbers are 38 48 26 45 35 14 and the user inputs 38 46 51 (the example you have provided)? Commented Jul 19, 2015 at 20:08
  • Amit this is the problem i am having. C.Evenhuis no in this case it should not , that was just an example of what i am trying to do. Commented Jul 19, 2015 at 20:12
  • Being unable to uniquely identify the separator seems like a very serious problem to me. I would start from solving that. Commented Jul 19, 2015 at 20:16

1 Answer 1

2

Assuming, 4 would be entered as 04 , and all numbers have 2 long, you can do this :

var input = "38482645351404";
var numbers = Enumerable.Range(0, input.Length/2).Select(i => int.Parse(input.Substring(i*2, 2))).ToArray();
Sign up to request clarification or add additional context in comments.

1 Comment

That did it thanks you, I will have do more research on substrings , thank you very much for your time.

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.