Wish Initialize variable, types, list, etc. by the key word "new"

Alexander Stolte

Expert
Licensed User
Longtime User
Hey, i'm working with Visual Studio every day and there is a Feature to Initialize all with the keyword "new" for example:

Dim str as new string
Dim mytype as new nicetype

You could initialize lists for example in the Process_Globals already at the declaration.

Would that be possible someday?
 
Not really dangerous. It depends on your requirements.

If you want to create a mutable list then write it like this:
Code: Copy
Dim list As List
list.Initialize
list.AddAll(Array(1, 2, 3))
Or:
Code: Copy
Sub CreateMutableList(Items As List) As List
 Dim list As List
 list.Initialize
 list.AddAll(Items)
 Return list
End Sub

Dim list As List = CreateMutableList(Array(1, 2, 3))
list.Add(4)
 
Back
Top