System.NuReferenceException: 'Object was set with an object made.' how to fix?

Zaug 306 Reputation points

string metinok;
metinok = mainwindowtest.Text;
int konumok = -1;
string kelimeok = "=>";

            konumok = metinok.IndexOf(kelimeok, konumok + 1);
            if (konumok != -1)
                if (runGame == true)

I do not know what to say. it wasn't just being young, now this error pops up (in the title)

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,034 questions
{count} votes

Accepted answer
  1. Timon Yang-MSFT 9,551 Reputation points

    The reason for the problem is here:

            public MainWindow()  

    We need to put the InitializeComponent method above the ZaugLanguage method.

    We can know from the name that this method is used to initialize the component. If the component has not been initialized, then of course a NuReferenceException will appear when we try to call it.

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful