Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

NullReferenceException: Object reference not set to an instance of an object

luke123tluke123t Member
edited April 2021 in Brackeys' Tutorials

Answers

  • NullReferenceException means that you are trying to use a reference variable whose value is Nothing/null . When the value is Nothing/null for the reference variable, which means that it is not actually holding a reference to an instance of any object that exists on the heap.

     string str = null;

    str.ToUpper();

    Above c# code throws a NullReferenceException at the second line because you can't call the instance method ToUpper() on a string reference pointing to null. So, check your code once again.

Sign In or Register to comment.