Put specific line of txt in array

后端 未结 2 871
小鲜肉
小鲜肉 2021-01-24 13:37

I am making a \"Who wants to be a millionare\" game for my c# class, and I have 15 txts with 3 questions/answers each. example:

Whats the capital of Brasil? || Rio

相关标签:
2条回答
  • 2021-01-24 14:02

    If you have to go this way, all you have to do is to use a different delimiter for the entire question than you use for the parts of the question. This way you will be able to tell where the question ends and another starts.

    Say you use "||" for the parts of a question, then each new line maybe a separate question(new line characters are the question delimiters in this case) and it's answers, like this:

    • Question? || Answer || Answer
    • Question? || Answer || Answer
    • Question? || Answer || Answer

    Mapping your two dimensional array:

    • [0,1] || [0,2] || [0,3]
    • [1,1] || [1,2] || [1,3]
    • [2,1] || [2,2] || [2,3]

    Or you can use your own delimiter. It can be anything that you know will never be a part of a question or an answer texts. Say: {{Delimiter}}, this is just a clue for you. Then your text file will look something like:

    • Question? || Answer || Answer {{Delimiter}} Question? || Answer || Answer {{Delimiter}} Question? || Answer || Answer

    These are just concepts.

    0 讨论(0)
  • 2021-01-24 14:06

    I don't think we're technically supposed to answer homework questions, so I shall point you in the right direction: Google. Try inputting 'C# multidimensional array' and looking for the link to the MSDN library. There are a fair number of samples that can be adapted to your purpose.

    Note that the commenter above is right; most often in programming you won't find decimals used for item division and rather commas. I know European-style numbers use commas to denote what decimals do in the US and vice-versa, but to my knowledge most programming languages were designed with American English in mind. This means that 2.25 means 2 and one quarter, where 2,25 indicates a list of 2 and 25.

    0 讨论(0)
提交回复
热议问题