Skip to content

Creating an array of size n at runtime

George Loveless

Asked Sep 29, 2008, 8:44 PM EDT1 answer
Share
LinkedInX

I'm reading an unknown number of characters for a text file and placing them in an arrray.  I will not know the length  until run time so i was just wondering the best way to do this is C#.  I'm somewhat new to the language.  thanks in advance.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • +1
    char[] myArray = new char[n];

    Should work... where n is whatever number you need to create the size of the array to.
    +1