开发者

setting strings_array(0) = "" problem

im getting an exception on this:

Dim strings_extreme As String()
strings_extreme(0) = ""

it says that i am using it before it is being assigned a value

how do i initialize it?

please note 开发者_开发问答that i need to be able to do this:

strings_extreme = input.Split(","c).Distinct().OrderBy(Function(s) s)


If you truly don't know how many strings there are going to be, then why not just use an IList:

Dim stringList As IList(Of String) = New List(Of String)
stringList.Add("")

You can get the Count of how many strings there are and you can For Each through all the strings in the list.

EDIT: If you're just trying to build an array from a Split you should be able to do this:

Dim strings_extreme() As String = input.Split(...)


Dim strings_extreme As List(Of String) = New List(Of String)
strings_extreme.Add("value1")
strings_extreme.Add("value 2")
strings_extreme.Add("value 3rd")
strings_extreme.Add("value again")

Dim strings() As String = strings_extreme.ToArray()

...


Dim strings_extreme(10) As String
strings_extreme(0) = ""

Further info: http://www.startvbdotnet.com/language/arrays.aspx


Dim strings_extreme as String() = {"yourfirstitem"}

But actually, why not take a look at some more advanced data structure from System.Collections namespace?


Shouldn't bother setting a string to "".

Try using:

Dim strings_extreme(10) As String
strings_extreme(yourIndex) = String.Empty
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜