SHARE
TWEET

Untitled

a guest Jul 17th, 2017 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim lineItem = New With {.Name = myFile(index).Last_Name & ", " & myFile(index).First_Name, _
  2.                          .StartDate = myFile(index).Day,
  3.                          .EndDate = myFile(index).Day}
  4.    
  5. Public Function CreateListFromSingle(Of T)(ByVal p1 As T) As List(Of T)
  6.   Dim list As New List(Of T)
  7.   list.Add(p1)
  8.   return List
  9. End Function
  10.    
  11. Dim list = CreateListFromSingle(dsResource)
  12.    
  13. Public Function CreateEmptyList(Of T)(ByVal unused As T) As List(Of T)
  14.     Return New List(Of T)()
  15.   End Function
  16.  
  17.   Dim x = CreateEmptyList(New With { .Name = String.Empty, .ID = 42 })
  18.    
  19. Module Module1
  20.  
  21.     Sub Main()
  22.         Dim dsResource = New With {.Name = "Foo"}
  23.  
  24.         Dim List = dsResource.CreateTypedList
  25.     End Sub
  26.  
  27.     <System.Runtime.CompilerServices.Extension()> _
  28.     Function CreateTypedList(Of T)(ByVal Prototype As T) As List(Of T)
  29.         Return New List(Of T)()
  30.     End Function
  31.  
  32. End Module
  33.    
  34. Sub Main()
  35.     Dim x = New With {.Name = "Bob", .Number = 8675309}
  36.     Dim xList = {x}.ToList()
  37. End Sub
  38.    
  39. Dim yourList = {(New With {.Name="", .Age=0})}.Take(0).ToList
  40.    
  41. Public Function EnumerateFromSingle(Of T)(ByVal p1 As T) As IEnumerable(Of T)
  42.     Return New T() { p1 }
  43. End Function
  44.    
  45. Dim l = dsResources.Select(Function(d) New With {
  46.                               .Name = d.Last_Name & ", " & d.First_Name
  47.                           }).ToList()
  48.    
  49. Dim aList = {(New With {.Name="John", .Age=30}),(.Name="Julie", .Age=32)}.ToList
RAW Paste Data
Top