Dillinger Dillinger - 5 months ago 12x
Vb.net Question

What is the equivalent of ReDimStatement in c#?


I've this code block:

Public Sub AddItem(Text As String, Optional Left As Integer = 0, Optional Header As Boolean = False)
Dim Item As ListItem
ReDim Item.Text(0)
Item.Text(0).Text = Text
Item.Text(0).Left = Left
Item.Header = Header
End Sub

UPDATE: ListItem

Public Structure ListItem
Dim Text() As ListText
Dim Header As Boolean
End Structure

this code allow me to add an item to a list,
allocate the storage space for an array variable in vb.net, in c# what is the equivalent of this code? I also tried to convert it on converter.telerik.com without success.

ReDim Item.Text(0)

in VB is the same as

Item.Text = new String[1];

in C#. But you might want to take a step back here and ask what the program is actually doing, and then write a more idiomatic C# program. In particular, should Text be a List<string> instead of an array?