Adding values to an open ended array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kcdpas
    New Member
    • Oct 2008
    • 2

    Adding values to an open ended array

    I am new to C#. Is any one know how to add a series numbers via Console.Write to an open ended array? I think a while loop could accomplish that when sentinel value entered but having trouble to do so:). Thanks!
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Console.Write() sends output to the console. You can't do anything other than that with it.

    Comment

    • kcdpas
      New Member
      • Oct 2008
      • 2

      #3
      Originally posted by insertAlias
      Console.Write() sends output to the console. You can't do anything other than that with it.
      Yes, i left Console.Read() which captures user input. but I don't know how to put that value into an open ended array.

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        I'm not sure what you mean by open-ended array.

        Arrays in C# have defined lengths. What you might want is a List. If these are numbers, you would use List<int> or List<double>.

        Something like this:
        Code:
        List<int> lst = new List<int>();
        int i = 20;
        lst.Add(i);
        And you can get a fixed length array from the list once you are done.

        Hope that helps.

        Comment

        Working...