✅ object reference not set to an instance of an object (beginner)
Hello. I am working on a Registration / login system for a bigger project. I am getting an exception thrown when it hits the login portion of the createuser class. I have a bunch of other issues to solve but this is the current problem I am working to solve. if anyone has any clues please feel free to tear this apart.
Thanks in advance for the assistance.
12 Replies
Second page
why are you doing this?
you never set that
static createuser newUser
to anythingOh I think visual studio did that as a potential fix one time. Forgot it was there. Is that the issue?
Yes
this right here
in the
if
block, you declare a local variable called newUser
. this variable is never used and forgotten about
in the else if
block, you use the private static createuser newUser
variable you have in your class. this is never set to anything and remains null
these things are easily fixed when just conforming to c# naming conventions and looking at the colors of the variables in your editorWait that is local? So how do i make it usable elsewhere? I thought this is how you create the class object.
just
Ahhh ok I see. I will have to work on this. Thanks. Do you see any other issues I might run into with the structure I have now?
hey Ero. I tried it with newUser = new createuser(); and there is no context for it to work. would I have to create the variable of newUser first for it to work? but then it wouldnt be a class object anymore. right?
No that definitely should work
Otherwise the else if block would fail too
what's a class object?
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.yes I was able to resolve the issue. Thank you for your help