String Array question..
-
Can we have an string array and add strings elements to it at random points of time, without using a for loop??
Som
You can not add element to array. Array has fixed lenght. You can only change any element in array any time:
myArray[0] = "hey bob!";
if you need to add element to array you need to create a new array(with more elements) and copy elements from old arrray to it together with you new elements. But this is pretty much what List does, so if you need to add elements to array often at runtime I would recommend you to use List which also has a method called ToArray which return current state of List as regular array. hth -
Can we have an string array and add strings elements to it at random points of time, without using a for loop??
Som
you can use arraylist for this purpose
-
you can use arraylist for this purpose
Nouman Bhatti wrote:
you can use arraylist for this purpose
No one uses the ArrayList anymore. The generic types in C# 2.0 have rendered it obsolete. I suggest you check out the Generic List<>[^] type instead.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
-
Can we have an string array and add strings elements to it at random points of time, without using a for loop??
Som
You can use generic
List<string>
class.All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions