Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8664909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:21:14+00:00 2026-06-12T17:21:14+00:00

I am new to .net. I have a form in which there are two

  • 0

I am new to .net. I have a form in which there are two comboboxes cbProduct and cbBrandName and also a label lblPrice.

I am trying to implement the below code but it is showing blue scribbles to &&.
(Error: operator ‘&&’ cannot be applied to operands of type ‘lambda expression’ and ‘lambda expression’)

I tried the below code: (not working)

lblPrice.Text = string.Empty;
        lblPrice.Text = doc.Descendants("items"
            ).Where((x => x.Element("productname"
                ).Value.Equals(cbProduct.SelectedItem.ToString())) && /*blue scribbles to '&&'*/
                (y => y.Element("brandname").Value.Equals(cbBrandName.SelectedItem.ToString()
                ))).Select(k => k.Element("price"
                    ).Value).ToString();

My other question is that i want to make the selected values of cbProduct as distinct. The below code takes all the values instead of distinct values:

cbProduct.Items.AddRange(doc.Descendants("items"
            ).Select(x => x.Element("productname").Value
            ).ToArray<string>());//adds all products           
        cbProduct.SelectedIndex = 0;

giving any one answer is ok

Please assist me

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:21:15+00:00Added an answer on June 12, 2026 at 5:21 pm

    For the first question, it looks like you just want to select the one price. This code will work, assuming that the item is found by the .Single(). It will throw otherwise, in which case you should use .SingleOrDefault() and check for null on the found item.

    lblPrice.Text =
        doc.Descendants("items")
           .Single(x => x.Element("productname").Value == cbProduct.SelectedItem.ToString() &&
                        x.Element("brandname").Value == cbBrandName.SelectedItem.ToString())
           .Element("price").Value;
    

    For the second question, you need to close off your .Select with a bracket, then you can call .Distinct() and .ToArray() to filter to distincts and project the result to string[]. I’ve also thrown an .OrderBy() in there, as there’s nothing more annoying than a ComboBox in a random order. Try this:

    cbProduct.Items.AddRange(doc.Descendants("items")
                                .Select(item => item.Element("productname").Value)
                                .Distinct()
                                .OrderBy(item => item)
                                .ToArray());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scenario. (Windows Forms, C#, .NET) There is a main form which
I am new to C#.Net. I have a form with some panels in it.
I am new to ASP.NET MVC, particularly ajax operations. I have a form with
I have a new asp.net mvc project and i am trying to figure out
I am new to .Net. I have two objects, Customer and Country in my
i have two tables which form part of my login/register system: these are userlogin
Possible Duplicate: Checking for an SQL result in VB.NET I have login form which
I have a ASP.NET MVC 3 view with esentially two forms, but which reside
I have a form in my asp.net mvc(C#) application which handles some dynamic controls.
I’m currently trying to have an attractive form part of which includes a keygen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.