A
A
authoraytee2020-07-26 20:17:33
C++ / C#
authoraytee, 2020-07-26 20:17:33

What does an uninitialized variable store in C#?

What does an uninitialized variable store in C#?
As far as I know, in C ++ such variables store any "garbage", in Java null, and for C # I did not find any information other than "give an error".

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
ayazer, 2020-07-26
@authoraytee

if the variable is declared, but not YET initialized - there will be a default value (null for classes, a specific value for structures (see default)). You can check it directly in the debugger.
will refer to a variable that is OBVIOUSLY not initialized at the moment of access (just the situation when there is some rubbish in it in c ++) - it is impossible, because this is considered a potential bug and such code will not even compile. (I suspect that the question was once about this part)

D
Developer, 2020-07-27
@samodum

Null

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question