![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
What is the correct syntax in VB.NET for checking that a value is in set of value ? pseudo code : value in ('a','b','c') ... |
#3
| |||
| |||
|
|
Mr. X. wrote: What is the correct syntax in VB.NET for checking that a value is in set of value ? pseudo code : value in ('a','b','c') ... What sort of set? If it's a List, then If myList.Contains(someValue) Then... -- Andrew |
#4
| |||
| |||
|
|
What should I do instead of : if a = 1 or a = 2 or a = 5 or a = 18 or a = 33 The pseudo code for short solution is : if a in (1,2,5,18,33) ... but the above does't work in VB.NET. What should I write instead of above ? |
#5
| |||
| |||
|
|
On 26/06/2010 19:15, Mr. X. wrote: What should I do instead of : if a = 1 or a = 2 or a = 5 or a = 18 or a = 33 The pseudo code for short solution is : if a in (1,2,5,18,33) ... but the above does't work in VB.NET. What should I write instead of above ? Dim values As New List(Of Integer)(New Integer() {1,2,5,18,33}) If (values.Contains(a)) Then . . . HTH, Phill W. |
#6
| |||
| |||
|
|
If this is the only solution, so I shall manage it. but it seems too complicated writing this on code - it's a basic thing. Each time I need this I shall write " if (new list(of integer)(New integer(){1,2,5,18,13}).contains(a) ... |
#7
| |||
| |||
|
|
If this is the only solution, so I shall manage it. but it seems too complicated writing this on code - it's a basic thing. |
#8
| |||
| |||
|
|
On 28/06/2010 16:28, Mr. X. wrote: If this is the only solution, so I shall manage it. but it seems too complicated writing this on code - it's a basic thing. "Basic" to you and I, perhaps, but how would Our Friends in Redmond set about implementing it as a Framework class? It would be some sort of "Set" class that you could create based on a given list of values. Then it would have to have a Contains method (or Intersection, if this is a Set). |
#9
| |||
| |||
|
|
What I meant is : dim a as integer ... a = 3 What should I do instead of : if a = 1 or a = 2 or a = 5 or a = 18 or a = 33 The pseudo code for short solution is : if a in (1,2,5,18,33) ... but the above does't work in VB.NET. What should I write instead of above ? |
#10
| |||
| |||
|
|
Phill W. expressed precisely : On 28/06/2010 16:28, Mr. X. wrote: If this is the only solution, so I shall manage it. but it seems too complicated writing this on code - it's a basic thing. "Basic" to you and I, perhaps, but how would Our Friends in Redmond set about implementing it as a Framework class? It would be some sort of "Set" class that you could create based on a given list of values. Then it would have to have a Contains method (or Intersection, if this is a Set). IEnumerable(Of T) already has an Intersect, Union, and Except as Extension methods. -- Tom Shelton |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |