Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

C# Problem?

Update:

I want an algorithm that stores a word into an array, of different letters, for example I would type in "Hello" and it would store 'H' Into word[1], then 'e' into word[2], and so on and so forth.This algorithm:

string []answer = new string[10];

for(int i = 0;i<answer.length;i++)

{

answer[i]= Console.ReadLine();

}

Almost helped me but it stored multiple characters into each array space, someone please help

2 Answers

Relevance
  • 5 years ago

    You are looping from 0 to the length of the String, but inside the loop you're assigning the value in the array equal to the value returned from Console.ReadLine. jzimmerman56301 suggested the most practical solution of using ToCharArray, but I've included an example as a fiddle in the sources showing how you'd do the same thing using a For/Next loop.

  • 5 years ago

    without the loop at all.. try a char array

    char [] answer=console.ReadLine().toCharArray();

Still have questions? Get your answers by asking now.