.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Searching a string in a list - generics

Posted By:nishithraj       Posted Date: December 23, 2009    Points: 25    Category: .Net Framework    URL: http://www.dotnetspark.com  

Searching a string in a list - generics. We can have a static generic list item to hold the keywords to be searched.

We can search for a particular keyword using Contains function. Return type of this function is a boolean.
Which ease the way of database search. In case if we want to search through database we require to do the query for that.

The code piece for the searching in a generic list is as follows,

using System;
using System.Collections.Generic;
using System.Text; 

public class CSharp 

  public static List<string> Keywords = new List<string>(

  new string[]{















  public static bool IsKeyword(string word)


  return Keywords.Contains(word);



  public static string Identifier(string word)


  if (IsKeyword(word))


  return "@" + word;




  return word;





 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend