You must Sign In to post a response.
  • Category: LINQ

    How to get specific Name from List using lambda expression

    How to get specific Name from List using lambda expression

    1. I need to get specific values form Lambda expression
    i need example please can any one send me
  • #756915
    Just try to find in LINQ as follow
    Currency result = FindItClass.Find(r => r.Code == searchFor);
    string strSearchResult = FindIt.Find(r => r == searchFor);

    Regards & thanks
    Arvind kumar
    Visit--blog.akumars.esoftera.in

  • #756946
    Hi,

    u can follow loke this:

    list<string> namelist=new list<string>
    (new string[] {"A","B","C"});

    var name=namelist.find(namelistobj=>namelistobj=="A");

    Then u can get the specific name from list


    Otherwise u can write like wise:
    var name=namelist..select(namelistobj=>namelistobj=="A");

    hopr it will helpful for uu..

    Thanks,
    Chitaranjan

  • #756948
    Hi,

    u can go through the below sample code in two ways like :


    List<string> namelist = new List<string>(new string[] { "A", "B", "C" });
    // Lamda expression
    // var link = namelist.Select(namelistobj => namelistobj).Where(item=>item=="A");

    // LinkQuerry
    var link = from name in namelist where name == "A" select name;

    foreach (string nameval in link)
    {

    Console.WriteLine(nameval);
    Console.ReadLine();
    }

    Try and checkit out , it will helpful for uu..

    Thanks,
    CHitaranjan


  • Sign In to post your comments