R
RayLopez99
Thanks to Goran, I figured out a while ago how to use a method for
IEqualityComparer. Also I've figured out how to use LINQ. But for
shorthand, I'd like to know if there's an "inline" way of
using .Contains on an array to find a value.
Say you have an array: AnArrayContainingIntegers.
You want to find if any number less than or equal to "13" exists in
this array.
Can you do this *without* using a method for IEqualityComparer? Can
you do it, in other words, inline?
I've tried various things but nothing compiles.
so:
int testInteger = 13;
bool testBool = AnArrayContainingIntegers.Contains(13,
IEqualityComparer<int> comparer);
is the template, but what to put on the RHS for IEqualityComparer<int>
comparer?
Again, I can do this using a method/function with template
IEqualityComparer, but I'm trying to see if there's a way to do it
"inline".
Also using LINQ I can do this along the lines of AnArray.Where (x => x
<= testInteger), etc, but I'm looking for using IEqualityComparer in
this example (something for my library).
RL
IEqualityComparer. Also I've figured out how to use LINQ. But for
shorthand, I'd like to know if there's an "inline" way of
using .Contains on an array to find a value.
Say you have an array: AnArrayContainingIntegers.
You want to find if any number less than or equal to "13" exists in
this array.
Can you do this *without* using a method for IEqualityComparer? Can
you do it, in other words, inline?
I've tried various things but nothing compiles.
so:
int testInteger = 13;
bool testBool = AnArrayContainingIntegers.Contains(13,
IEqualityComparer<int> comparer);
is the template, but what to put on the RHS for IEqualityComparer<int>
comparer?
Again, I can do this using a method/function with template
IEqualityComparer, but I'm trying to see if there's a way to do it
"inline".
Also using LINQ I can do this along the lines of AnArray.Where (x => x
<= testInteger), etc, but I'm looking for using IEqualityComparer in
this example (something for my library).
RL