using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace GermanFlash
{
    class Program
    {
        static void Main(string[] args)
        {
            string[,] flashes = new string[,] { {   "Der Himmel", "Die Sonne", "Das Wetter", "Der Freund", "Die Freundin", "Das Auslandsamt", "Das Buch", "Die Karte", "Die Mensa", "Die Vorlesung", "Beginnen", "Gehen", "Kaufen", "Kommen", "Machen", "Regnen", "Scheinen", "Schreiben", "Studieren", "Schon", 
                                                    "Windig", "Dann", "Gleich", "Heute", "Heute Nachmittag","Jetzt", "Morgen", "Oft", "Zuerst", "Auch", "Ein Paar", "Fast", "Nicht", "Gar Nicht", "Noch", "Noch Nicht", "Nur", "Viel", "Bis Spater", "Klar", 
                                                    "Mensch", "Toll", "Das Thermometer", "Bitte", "Danke", "HeiB", "Kalt", "Richtig", "Falsh", "Blau", "Braun", "Gelb", "Grau", "Grun", "Rosarot", "Rot", "Schwarz", "Violett", "WeiB",
                                                //59
                                                    "Der Tag", "Die Woche", "Der Montat", "Das Jahr", "Die Jahreszeit", "Der Fruhling", "Der Sommer", "Der Herbst", "Der Winter", "Der Mitbewohner", "Die Mitberwohnerin", "Das Zimmer", "Arbeiten", "Finden", "Fliegen", "Glauben", "Kosten", "Lernen", "Reisen", "Sitzen", 
                                                    "Spielen", "Stehen", "Tanzen", "Tun", "Und", "Oder", "Denn", "Aber", "Sondern", "Wann", "Warum", "Was", "Wer", "Wie", "Wie Viel", "Wie Viele", "Wo", "Woher", "Wohin", "Interessant", 
                                                    "Sportlich", "Nichts", "Sehr", "Ubrigens", "von...bis", "Wieder", "Zusammen", "Die Frage", "Die Antwort", "Fragen", "Antworten", "Gut", "Schlecht", "Hell", "Dunkel", "Hier", "Dort", "Viel", "Wenig", "in die Bibliothek",
                                                    "In die Disco", "In die Kneipe", "In die Mensa", "In die Vorlesung", "Ins Bett", "Ins Kino", "Ins Konzert", "Ins Theater", "Der Montag", "Der Dienstag", "Der Mittwoch", "Der Donnerstag", "Der Freitag", "Der Samstag", "Der Sonntag", "Der Januar", "Der Februar", "Der Marz", "Der April", "Der Mai", 
                                                    "Der Juni", "Der Juli", "Der August", "Der September", "Der Oktober", "Der November", "Der Dezember",
                                                //87
                                                    "Die Freundschaft", "Der Lehrer", "Die Schule", "Der Schuler", "Die Briefmarke", "Die Zeitung", "Haben", "Kocken", "Sagen", "Sammeln", "Telefonieren", "Blod", "Doof", "Bis", "Immer", "Miteinander", "Bei uns", "Ich Koche gern", "GroB", "Klein", 
                                                    "Intelligent", "Dumm", "Mollig", "Schlank", "Die Zeit", "Die Minute", "Die Sekunde", "Die Stunde", "Stundenlang", "Die Uhr", "Das Getrank", "Das Bier", "Die Cola", "Der Kaffee", "Die Milch", "Der Tee", "Das Wasser", "Der Wein", "Sport machen", "Fitnesstraining machen", 
                                                    "Basketball spielen", "Eishockey spielen", "FuBball spielen", "Golf spielen", "Joggen gehen","Schwimmen gehen", "Snowboarden gehen", "Tennis spielen", "Wandern gehen", "Windsurfen gehen",
                                                //50
                                                    
                                                },{"Sky", "Sun", "Weather", "Boyfriend", "Girlfriend", 
"Foreign students office", "Book", "Card", "Caf", "Lecture", 
"To begin", "to go", "to buy", "To come", "to do", 
"to rain", "to shine", "To write", "To study", "Beautiful", 
"Windy", "Then", "Right away", "Today", "This afternoon", 
"Now", "Tomorrow", "Often", "First", "Also", 
"A few", "Almost", "Not", "Not at all", "Still", 
"Not yet", "Only", "Much", "See you later", "Of course",
"Wow", "Fantastic", "Thermometer", "Please", "Thank you", 
"Hot", "Cold", "True", "False", "Blue", 
"Brown", "Yellow", "Grey", "Green", "Pink", 
"Red", "Black", "Purple", "White",
                                                  
"Day", "Week", "Month", "Year", "Season", 
"Spring", "Summer", "Autumn", "Winter", "Male Roommate", 
"Female Roommate", "Room", "to work", "to find", "to fly", 
"To believe", "To cost", "To learn", "To Travel", "To sit", 
"To play", "To stand", "To dance", "To do", "When", 
"Why", "What", "Who", "How", "How much",
"How many", "In what place", "Where...from", "To what place", "Interesting", 
"athletic", "Nothing", "Very", "By the way", "from...to", 
"again", "together", "Question", "answer", "to ask", 
"to answer", "good", "bad", "Light", "Dark", 
"Here", "There", "Much", "Little", "To the Library", 
"To the disco", "To the pub", "To the cafeteria", "To the Lecture", "To Bed", 
"To the movies", "To a concert", "To the theatre", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", 
"January", "Febuary", "March", "April", "May", 
"June", "July", "August", "September", "October", 
"November", "December",
                                                  
"Friendship", "Teacher", "School", "Student", "Postage stamp", 
"Newspaper", "To have", "To cook", "To say", "To collect", 
"To talk on the phone", "Stupid", "Nice", "Until", "Always", 
"Together", "At our house", "I like to cook", "Big", "Little", 
"Intelligent", "Stupid", "Plump", "Slim", "Time", 
"Minute", "Second", "Hour", "For hours", "Clock", 
"Beverage", "Beer", "Cola", "Coffee", "Milk", 
"Tea", "Water", "Wine", "To do sports", "To work out", 
"to play basketball", "To play hockey", "To play soccer", "To play golf", "To go jogging", 
"To go swimming", "To go snowboarding", "To play Tennis", "To go hiking", "To go windsurfing",
                                                           } };
            
            Random rdmL = new Random();
            int Deutsch;
            int English;
            string answ;
            for (int i = 0; i < 2; )        //Creates an infinite Loop that will cause the questions to never end
            {
                int Lang = rdmL.Next(0, 2); 
                if (Lang == 1)
                {
                    Deutsch = 0;            //Sets the output language as Deutsch
                    English = 1;            //Sets the input language as English
                }
                else
                {
                    Deutsch = 1;            //Sets the input language as Deutsch
                    English = 0;            //Sets the output language as English
                }

                Random rdmP = new Random();
                int Place = rdmP.Next(0, 196);
                Console.WriteLine(flashes[Deutsch, Place]);
                answ = Console.ReadLine();
                if (answ == flashes[English, Place])
                {
                    Console.WriteLine("Yay, you got it!");
                }
                else
                {
                    Console.WriteLine("Sorry, that's not it... The answer was actually {0}", flashes[English, Place]);
                    
                }
                Console.WriteLine("Now to the next one!");
                
            }
        }
    }
}

I've probably missed something stupid, but for what ever reason after my array gets slightly large, I run into an "Invalid rank specifier" error on line 29, where I declair the second half of the array.
Any thoughts?

Recommended Answers

All 5 Replies

Hi, Acadian, welcome to Daniweb.
I think the comments you placed in are causing some trouble here.

if you use comments inside a CSV type initializer its practice to use /*comment*/ multi-line compatible comment blocks. although technically it shouldn't matter. but you never know what the compiler is doing to the text so being SURE where you comment terminates does help rule it out of the problem.

I haven't tested the code (beyond this) or looked for other issues, but the array initializations are off. The first set of strings includes 196 elements, but the second is only 191. A 2D array needs to be uniform.

commented: Good eye. I never would have counted 200 array elements +3
commented: remarkable observation. +6

Apparently I missed some elements, somewhere along the line, and hadn't noticed that. Thanks a lot, but I feel I have to ask, how did you find out that there were 196 vs 191? Did you actually count them by hand? Or did you do something more time efficient then that.
Again, thank you Apegram.

Oh, gracious no. I didn't count by hand. It was more like

string[] array = { * your second set of elements here * };
int i = array.Length; // 191
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.