Skip to content

How to check string with database

Asp.Net Hein

Asp.Net Hein

Asked May 12, 2015, 7:21 PM EDT1 answer
Share
LinkedInX
How to check string object and with this (var list = (from x in eb.registrations select x.Name.ToString()).ToList();)
 
Esp: I want to check one string element is included or not in var list .
 
Can anyone help me in my problem?
Thanks a lot for viewing my post :-)  

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Manoj Bhoir
    0
    Hi,

    I think you can use Contains and Exist methods on a List<T>.

    See this example :

    var list = new List<string>();
        list.Add("cat");
        list.Add("dog");
        list.Add("moth");

        // 2. Search for this element.
        if (list.Contains("dog"))
        {
            Console.WriteLine("dog was found");
        }

    For more details check this link :

    List<T>.Contains Method
    https://msdn.microsoft.com/en-us/library/bhkz42b3%28v=vs.110%29.aspx
    0