Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Error CS0019: Operator `==' cannot be applied to operands of type

Discussion in 'Scripting' started by heyramb89, Jan 10, 2019.

  1. heyramb89

    heyramb89

    Joined:
    Dec 29, 2018
    Posts:
    29
    I am getting this error while randomizing array.
    Please check the attached image.
     

    Attached Files:

  2. GeekStories

    GeekStories

    Joined:
    Jan 22, 2015
    Posts:
    74
    I believe
    Code (CSharp):
    1. unansweredQuestions == 0
    is causing the error as you're trying to compare a List<T> to an Int.
     
    xVergilx likes this.
  3. heyramb89

    heyramb89

    Joined:
    Dec 29, 2018
    Posts:
    29
    Now it's showing this error.

    ArgumentNullException: Argument cannot be null.
    Parameter name: source
    System.Linq.Check.Source (System.Object source)
    System.Linq.Enumerable.ToList[QuestionData] (IEnumerable`1 source)
    GameController.Start () (at Assets/Scripts/GameController.cs:45)

    :(:(:(
     
  4. Subliminum

    Subliminum

    Joined:
    Nov 9, 2017
    Posts:
    97
    Shouldnt if(unansweredQuestions == 0 || unansweredQuestions.Count == 0) be,
    if(unansweredQuestions==null). Plus you should really be either checking that after you try to initialize unansweredQuestions = question.ToList<QuestionData>(); , or instead check that if(questions!=null) to ensure that GetRandomQuestion() can run its logic on the unansweredQuestions Array.
     
    Last edited: Jan 11, 2019
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    "Now?" What did you change?