that array contains the first string, between the array and the string, which of the two uses more memory?
both array and string are struct type. the memory used by the string is actually inside the memory used by the array
String uses a bit more as it doesn't have a size and it needs pointer to the memory where the string is stored and information on its length... but it is much easier to use string compared to string array.
Well, I thought c# strings have their sizes determined by the number of char values in them?
That wouldn't really work in real life because if the size of the string changes then it is a problem for example when you define a string it is always 0 length, but when you put something in it, it gets bigger and you could simply do a += "TEST"; And it'll get bigger, this is an issue because if there is something in the way like the memory is used by some other variable, it has to jump it or move it, this can't happen... This is why C# would maintain a special area for strings and manage it there, which has to have length associated with it... (I guess) otherwise it won't be able to keep the information or change it. While string array or char array has a limitation of size, you can't overflow the length... and it has null termination.
At runtime, what memory do text boxes use or any data container use to store data?
Обсуждают сегодня