Hi Team,
How can i initialize string? I will be adding element to it on run time inside a for loop
Thanks
Hi Team,
How can i initialize string? I will be adding element to it on run time inside a for loop
Thanks
Hi,
You have to make the difference between String Arrays and String Lists.
How to initialize both :
myStringArray = new System.String(){}
myStringList = new System.Collections.Generic.List(Of String)
Best regards,
Mustafa
its string array…
if I try to do something like this I am getting error - “Index was outside the bounds of the array.”
myStringArray = new System.String(){}
myStringArray(0) = “Test Data”
Hi @Deeipauk
You might need to specify the length of the array. Try to I initialize it with specified length and let us know if it helped:
new System.String(3){}
Hi @Deeipauk,
arrvariable - String
arrvariable={"a","b","c","d"}
you can directly assign the value.its fixed length if you are going to dynamic go to list of string.
listvariable- list of string variable
use the below code to create a object
listvariable=new list(of String)
Only use arrays if you know the number of items it will contain. Otherwise, go for Lists
Thanks everyone for the response @loginerror @mustafa.altinbasak
I have already changed it into the Lists, I was bit hesitating to use “Add to collection” and all imagining it will complicate my code . After I made it to List String and with add to collections component it got easier. I am able to finish it
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.