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 6007815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:44:10+00:00 2026-05-23T01:44:10+00:00

I am running the following: var abc = new adminModel(); string text = abc.AnswerType.SingleOrDefault(s

  • 0

I am running the following:

var abc = new adminModel();
string text = abc.AnswerType.SingleOrDefault(s => s.Value == "2");
string text0 = abc.AnswerType.Single(s => s.Value == "2").Text;
var text1 = (from a in abc.AnswerType 
  here a.Value == "2"
  select a.Text).SingleOrDefault();

Where AnswerType looks like this:

public class adminModel
{

    public IEnumerable<SelectListItem> AnswerType
    {
        get
        {
            return new[]
                {
                    new SelectListItem { Value = "1", Text = "1 answer" },
                    new SelectListItem { Value = "2", Text = "2 answers" },
                    new SelectListItem { Value = "3", Text = "3 answers" },
                    new SelectListItem { Value = "4", Text = "4 answers" },
                    new SelectListItem { Value = "5", Text = "5 answers" },
                    new SelectListItem { Value = "6", Text = "6 answers" },
                    new SelectListItem { Value = "7", Text = "7 answers" },
                };
        }
    }

}

But I am getting an error message saying that “Can’t convert SelectListItem to string”. Is there a way that I can just extract the Text from the SelectListItem?

  • 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-05-23T01:44:11+00:00Added an answer on May 23, 2026 at 1:44 am

    In your code AnswerType.SingleOrDefault(s => s.Value == "2") will return SelectedListItem instance, not a string.

    If you need to get text the query would be:

    string text = AnswerType.Single(s => s.Value == "2").Text;
    

    or

    string text = AnswerType
        .Where(s => s.Value == "2")
        .Select(arg => arg.Text)
        .SingleOrDefault();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a method chain like the following: var abc = new ABC();
I have the following code: var searcher = new ManagementObjectSearcher(SELECT Name, Path FROM Win32_share);
Running the following code: for (var i=0; i<3; i++) { setTimeout( function() { console.log(i);
When I invoke rake ts:rebuild RAILS_ENV=production , I get the following: (in /var/www/abc.com/public/abc/releases/20101008073517) **
When running the following block of code, FF and Chrome output typeof(hiya) = string
I am running following code : https://github.com/rjrodger/simpledb var simpledb = require('simpledb'); var sys =
I am running following PHP code to interact with a MS Access database. $odbc_con
When running the following code it leaves out one row. When I do a
When running the following Java code, I get very accurate and consistent results in
When I am running the following statement: @filtered = map {s/&nbsp;//g} @outdata; it is

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.