Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.76 KB | None | 0 0
  1. Sub Main
  2.  
  3.     Dim sample = Enumerable.Range(1, 4).Select(Function(x) New GatesPositions With
  4.         {
  5.             .intValue = CByte(x * 10),
  6.             .Items = New Stack(Of Data)(enumerable.Range(0, 3).Select(Function(i) New data With
  7.             {
  8.                 .X = i,
  9.                 .Y = i * 2
  10.             }))
  11.         }).ToArray
  12.  
  13.     sample.Dump
  14.  
  15.  
  16.     Dim by20 = GetByRoll(sample, 20)
  17.  
  18.     by20.Dump("By 20")
  19.  
  20.  
  21. End Sub
  22.  
  23. ' Define other methods and classes here
  24. Public Structure GatesPositions
  25.     Public intValue As Byte
  26.     Public Items As Stack(Of Data)
  27.  
  28. End Structure
  29.  
  30. Class Data
  31.     Property X As Integer
  32.     Property Y As Integer
  33. End Class
  34.  
  35. Function GetByRoll(source As ienumerable(Of GatesPositions), roll As Integer) As IEnumerable(Of GatesPositions)
  36.  
  37.     Return source.Where(Function(g) g.intValue - roll <= 0)
  38.  
  39. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement