C#中的初始化和赋值有什么区别 [英] What's the difference between Initialization and Assignment in C#
本文介绍了C#中的初始化和赋值有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
C#变量初始化与赋值
Possible Duplicate:
C# variable initializations vs assignment
就像标题中一样,有人可以解释一下C#中的Initialization和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
干杯, n1te
推荐答案
初始化变量时,您将其声明为存在.
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();
这篇关于C#中的初始化和赋值有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文