LINQ with ref parameter

capri

Active member
Joined
Jun 16, 2015
Messages
42
Programming Experience
5-10
Hi,


I'd like to know if it's possible to get a collection of something with LINQ with the 'where' clause equal to a function that has a ref parameter.


C#:
var objCol  = from id in ids
                        where id.GetValue(2, ref strValue) == "6"
                        select id;

The result should be based on the ref value.


Thanks
 
What happened when you tried? You say that the result should be "based" on the ref value. What does that actually mean? Are you saying that you want to get that value in the 'select' clause? If so then why aren't you doing that? Please be clear.
 
Yes, I mean the result of the query should be a list that contains objects that has the ref value. I've modified the code as this.

C#:
string strCheck = "1";

var objList = from object obj in objCol
                   where obj.GetValue("GroupName", 2, ref strValue) == strCheck
                   select obj;

But that's a syntax error which says operator cannot be applied to operand of type string.
 
But that's a syntax error which says operator cannot be applied to operand of type string.

Is that all it says and exactly what it says, or just an approximation? My guess is that it's talking about this:
C#:
obj.GetValue("GroupName", 2, ref strValue) == strCheck
Does GetValue return a string? If not then comparing its result to a string doesn't make sense.
 
Back
Top Bottom