Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Initialization and Assignment in C# [duplicate]

Possible Duplicate:
C# variable initializations vs assignment

Just like in the title, could someone please explain what is the difference between Initialization and Assignment in C#? I'm preparing for a test and I wanted to know what's the best way to answer this type of question. Thanks

Cheers, n1te

like image 935
n1te Avatar asked Dec 27 '22 14:12

n1te


1 Answers

When you initialize a variable you're declaring it into existence.

PlasticCup mySippyCup = new PlasticCup();

When you assign, you're just saying "this water" goes into "this cup". The cup already exists.

mySippyCup = new PlasticCup();
like image 51
Only Bolivian Here Avatar answered Jan 13 '23 20:01

Only Bolivian Here