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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:40:05+00:00 2026-05-27T20:40:05+00:00

Please help me with this error! Here ResultValue is an enumeration. Description: An error

  • 0

Please help me with this error! Here ResultValue is an enumeration.

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0019: Operator ‘==’ cannot be applied to operands of type ‘string’ and ‘Answer.ResultValue’

 Source Error:


   Line 38:                 Answer a = (Answer)al[i];
   Line 39: 
   Line 40:                 if (a.Result == Answer.ResultValue.Correct)
   Line 41:                     correct=correct+1;
   Line 42:             }

=================================

 using System;
 using System.Data;
 using System.Configuration;
 using System.Collections;
 using System.Web;
 using System.Web.Security;
 using System.Web.UI;
 using System.Web.UI.WebControls;
 using System.Web.UI.WebControls.WebParts;
 using System.Web.UI.HtmlControls;



  public partial class results : System.Web.UI.Page
 {
  protected void Page_Load(object sender, EventArgs e)
 {
    ArrayList al = (ArrayList)Session["AnswerList"];

    if (al == null)
    {
        Response.Redirect("History.aspx");
    }

    resultGrid.DataSource = al;
    resultGrid.DataBind();

    // Save the results into the database.

    if (IsPostBack == false)
    {
        // Calculate score
        double questions = al.Count;
        double correct = 0.0;


        for (int i = 0; i < al.Count; i++)
        {
            Answer a = (Answer)al[i];

            if (a.Result == Answer.ResultValue.Correct)
                correct=correct+1;
        }

        double score = (correct / questions) * 100;

        SqlDataSource studentQuizDataSource = new SqlDataSource();
        studentQuizDataSource.ConnectionString =             
         ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
        studentQuizDataSource.InsertCommand = "INSERT INTO UserQuiz ([QuizID],                 

          [DateTimeComplete], [Score], [UserName]) VALUES (@QuizID, @DateTimeComplete,               
              @Score, @UserName)";

        studentQuizDataSource.InsertParameters.Add("QuizID", 
          Session["QuizID"].ToString());
        studentQuizDataSource.InsertParameters.Add("Score", score.ToString());
        studentQuizDataSource.InsertParameters.Add("UserName", User.Identity.Name);
        studentQuizDataSource.InsertParameters.Add("DateTimeComplete",  
        DateTime.Now.ToString());

        int rowsAffected = studentQuizDataSource.Insert();
        if (rowsAffected == 0)
        {

            errorLabel.Text = "There was a problem saving your quiz results into our 
                               database.  Therefore, the results from this quiz will               
                                    not be displayed on the list on the main menu.";


        }

    }


}

protected void resultGrid_SelectedIndexChanged(object sender, EventArgs e)
{
    SqlDataSource1.FilterExpression = "QuestionOrder=" + resultGrid.SelectedValue;
 }

}

code for Answer.cs

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.Web.UI;
 using System.Web.UI.WebControls;

 public partial class Answer : System.Web.UI.Page
{
    private string m_QuestionID;
    private string m_CorrectAnswer;
    private string m_UserAns;
    private string m_Result;


    public string QuestionID
    {
        get
        {
            return m_QuestionID;
        }
        set
        {
            m_QuestionID = value;
        }
    }


    public string CorrectAnswer
    {
        get
        {
            return m_CorrectAnswer;
        }
        set
        {
            m_CorrectAnswer = value;
        }
    }


    public string UserAns
    {
        get
        {
            return m_UserAns;
        }
        set
        {
            m_UserAns = value;
        }
    }

    public string Result
    {
        get
        {
            if (m_UserAns == m_CorrectAnswer)
            {
                return "Correct";
            }
            else
            {
                return "Incorrect";
            }
        }
    }

public enum ResultValue
{
    Correct,
    Incorrect
 }


 }
  • 1 1 Answer
  • 1 View
  • 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-27T20:40:06+00:00Added an answer on May 27, 2026 at 8:40 pm

    It’s pretty obvious you’re trying to compare Enumeration Types with Strings, which aren’t the same and can’t be compared like that. Instead, I think you should try replacing this bit of code:

    public string Result
    {
        get
        {
            if (m_UserAns == m_CorrectAnswer)
            {
                return "Correct";
            }
            else
            {
                return "Incorrect";
            }
        }
    }
    

    with

    public ResultValue Result
    {
        get
        {
            if (m_UserAns == m_CorrectAnswer)
            {
                return ResultValue.Correct;
            }
            else
            {
                return ResultValue.Incorrect;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi Guys can you please help me with this error? What is it? Server
Please help! I have been grappling with this error for days and I cannot
can someone please help me. why does this return an error: Dim stuff As
So, out of the blue I get this error message. Description Resource Path Location
Here is the error: http://screencast.com/t/ZDVhNmJiOTgt Please help, here is my code: what can I
Please help me get to the bottom of this...the only file that this error
Please help me with this validation error. I can't understand what it means or
Please help this would be my last problem in dealing with access database with
Please help me convert this line to C#. objManagementBaseObject.SetPropertyValue(hDefKey, CType(&H & Hex(RegistryHive.LocalMachine), Long)) Related
Please help me about this issue... In my application i have calender where user

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.