Cannot implicitly convert type 'string' to 'TMPro.TextMeshProUGUI'

Hello im trying to put a string to a textmeshpro text but this error keeps showing up.
8872632--1211508--upload_2023-3-13_19-43-50.png
here’s my codes:

    [SerializeField]
    public TextMeshProUGUI resulttxt;
    [SerializeField]
    public TextMeshProUGUI explanationtxt;
    private string infp;


    void Start()
    {
        resulttxt.text = PlayerPrefs.GetString("typeA") + PlayerPrefs.GetString("typeB") + PlayerPrefs.GetString("typeC") + PlayerPrefs.GetString("typeD");
        ExplainType();
    }

    void ExplainType()
    {
        if (resulttxt = "INFP")
        {
            infp = "ate angel ganda";
            explanationtxt.text = infp;

        }
    }

UI view:
8872650--1211532--upload_2023-3-13_19-54-0.png

Here is how you can fix your own typing mistakes:

The complete error message contains everything you need to know to fix the error yourself.

The important parts of the error message are:

  • the description of the error itself (google this; you are NEVER the first one!)
  • the file it occurred in (critical!)
  • the line number and character position (the two numbers in parentheses)
  • also possibly useful is the stack trace (all the lines of text in the lower console window)

Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

Look in the documentation. Every API you attempt to use is probably documented somewhere. Are you using it correctly? Are you spelling it correctly?

All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.

Remember: NOBODY here memorizes error codes. That’s not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

Some help to fix “Cannot implicitly convert type ‘Xxxxx’ into ‘Yyyyy’:”

http://plbm.com/?p=263

Incorrect…

        if (resulttxt = "INFP")
        {
            infp = "ate angel ganda";
            explanationtxt.text = infp;
        }

Corrected…

        if (resulttxt.text  == "INFP")
        {
            infp = "ate angel ganda";
            explanationtxt.text = infp;
        }

I fixed it already I figured I can just put strings directly to the text, but thank you guys anyways!!

 void ExplainType()
    {
        //ANALYSTS=================================================
        if (resulttxt.text == "INTJ")
        {
            explanationtxt.text = "Thinkers who are creative and strategic, with a plan for everything.

" +
                "INTJs are analytical problem solvers who want to improve systems and processes with their creative ideas. 

" +
                "Suitable Strands:
 - ICT
 - STEM";

        }