Views on C# reporting the error of empty Object is null

      A problem in the project yesterday was that when switching the scene page, the error of the null pointer was reported, and it always showed that the object was not found. Since the code was written before, and the individual display UI was modified according to the opinions of the top leaders, it must be the later code problems. Sure enough, the added novice instruction guide UI needs to first determine whether it exists when the scene is switched, and it will report empty at this time. Because before this, I have closed this UI, of course it will be empty. So, especially when you look at the code of other people in the team, you must read it carefully.

  • The reasons for the general report are nothing more than these:
  • 1. The variable modifier is public, but it is not assigned a value in the monitoring view.
  • 2. If the initialization fails, the reference will naturally report null. Sometimes it is necessary to assign or search during the running of the program, and use the program to search without considering the hidden situation, which makes the reference report null errors.
  • 3. The object reference is correct, but it has been deleted by mistake before the operation.

Say these first, and then add some later.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325939353&siteId=291194637