syntax issue, converting a namevaluelistbase(of integer, string) to list(of string)

syntax issue, converting a namevaluelistbase(of integer, string) to list(of string)

Old forum URL: forums.lhotka.net/forums/t/10025.aspx


matt tag posted on Thursday, February 03, 2011

I need a List(of string) to supply as the property to a custom control  (an specialized type of autocompletetextbox).  I have a CSLA.NameValueListBase(Of integer, String)  that contains the values I want.  How do I use LINQ or whatever code to convert the CSLA object to the Generic List?

thanks

RockfordLhotka replied on Thursday, February 03, 2011

I think it is this:

Module Module1

  Sub Main()

    Dim obj = TestNvl.GetList
    Dim list = (From r In obj Select r.Value).ToList
    For Each item In list
      Console.WriteLine(item)
    Next
    Console.ReadLine()

  End Sub

End Module

<Serializable()>
Public Class TestNvl
  Inherits Csla.NameValueListBase(Of IntegerString)

  Public Shared Function GetList() As TestNvl
    Dim result = New TestNvl
    result.IsReadOnly = False
    result.Add(New TestNvl.NameValuePair(1, "dasf"))
    result.Add(New TestNvl.NameValuePair(2, "werew"))
    result.Add(New TestNvl.NameValuePair(3, "dfgdf"))
    result.Add(New TestNvl.NameValuePair(4, "zvzew"))
    result.IsReadOnly = True
    Return result
  End Function

End Class

Copyright (c) Marimer LLC