Adam Zastawski

My Personal Blog

Cute Little LINQ Trick

Posted by Adam

My friend Jesse showed me a cool little technique for introspecting a string array using Linq. Of course I realize that there a ton more fascinating Linq tutorials out there but this one showed me just how sweeping the effects of Linq are.

I first thought that Linq was just a neat way of generating a provider based Data Access Layer. Now I know that Linq can come in handy in a much broader array of solutions.

   1:  string[] textKeys = { "str1", "str2", "str3", "str4", "str5"};
   2:   
   3:  if (textKeys.Contains("str1"))
   4:  {
   5:       //do something here 
   6:  }

As I learn more about LINQ I will try to add some posts that actually provide more real-world value.

 

P.S. You will need to have "using System.Linq;"  in your 'using' statements.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Posted on: 4/21/2008 at 8:47 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (1) | Post RSSRSS comment feed

Related posts

Comments

Jesse Foster us

Monday, April 21, 2008 9:11 PM

Jesse Foster

Linq is awesome.

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Thursday, May 15, 2008 10:23 PM