5
Answers

C# - Generate Array at runtime

Mastermosley

Mastermosley

13y
2.2k
1
I have an array char[] buffer but I dont want to initialize it because I dont no how big its going to be. I have a simple StreamReader.Read() and I am processing each character, if the character is legit I add it to the buffer.

buffer[buffersize] = c;
buffersize++;

And if the char is a \r or \n thats a new line so I send the final buffer and process the command

if the char is 8 which is a backspace I want to delete the last character in the array.

buffersize--;

What I want to accomplish is that by subtracting 1 from the buffersize I want to delete the buffer[buffersize].

Any ideas am I missing something?
Answers (5)