Best Practice + Adding Items

I have a control which accepts objects of type   ValueListItem, is the following the best way of adding multiple items. Or should I stick with a single vli as just set it to a new one each time

       Dim vli1 As New Infragistics.Win.ValueListItem
        vli1.DisplayText = "Direct Database Connection"
        uceConnectionType.Items.Add(vli1)
        Dim vli2 As New Infragistics.Win.ValueListItem
        vli2.DisplayText = "Connect via Web Service"
        uceConnectionType.Items.Add(vli2)
rocky050371Asked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
I would say the second option is better.  Then you don't have a ton of variables declared cluttering up the code:

    Dim vli As Infragistics.Win.ValueListItem

    vli = New Infragistics.Win.ValueListItem
    vli.DisplayText = "Direct Database Connection"
    uceConnectionType.Items.Add(vli)

    vli = New Infragistics.Win.ValueListItem
    vli.DisplayText = "Connect via Web Service"
    uceConnectionType.Items.Add(vli)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.