SHARE
TWEET

spoulson

a guest Oct 14th, 2008 1,782 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Re: http://stackoverflow.com/questions/194930/how-do-i-use-linq-containsstring-instead-of-containsstring#194939
  2.  
  3. static void Main(string[] args) {
  4.    
  5.    var table = new[] {
  6.       new { uid = 1 },
  7.       new { uid = 2 },
  8.       new { uid = 3 },
  9.       new { uid = 4 },
  10.       new { uid = 5 }
  11.    };
  12.  
  13.    var stringarray = new[] { "1", "5", "10" };
  14.  
  15.    var results = from xx in table
  16.                  where stringarray.Contains(xx.uid.ToString())
  17.                  select xx;
  18.  
  19.    foreach (var result in results) {
  20.       Console.WriteLine("Result: " + result.uid.ToString());
  21.    }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top