• 0

C# Array


Question

Hello,

another small problem. The user needs to fill in a code, and the program has to check if the code is correct. By doing that, i'll need an array (with convert to chars i think) that declares the possibilities of the user input.

example :

A = 10, B = 12, C = 13, D = 14, the whole alfabet. (11, 22, 33 don't count)

Any idea how to do this?

thanks!

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

From what ive read it sounds like you want todo something like this? :

public char[] alphabet = new char[]{'a','b','c','d','e' /*....carry on here*/  };

If thats not what you want could you explain a bit more. :)

Dan

Link to comment
Share on other sites

  • 0

I know what your talking about. I was trying to do this too:

char[] alphabet = {"a", "1", "b", "2", "c", "3", "d", "4"};
int i = 0;
int j = 1;

while(j < 9)
{
     System.Console.WriteLine("\n{0} = {1}", alphabet[i], alphabet[j]);
     i+=2; /* Plus 2 */
     j+=2; /* Plus 2 */
}

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.