Const和Static之间的区别 [英] Difference between Const and Static
本文介绍了Const和Static之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
使用const和静态有什么区别
EQ。
Hi Friends,
What is difference between use of const and static
EQ.
public static string CSS_SELECTOR_TEMPLATE = "{0} > a";
我甚至可以写为
I can even write the same as
public const string CSS_SELECTOR_TEMPLATE = "{0} > a";
我发现只有差异是
静态变量可以替换为新值,但const不能。
两者都可以在不创建类对象的情况下访问,例如
Only difference I found is
static variable can be replaced with new value, but const cannot.
Both can be accessed without creation of object of the class, like
GridCellCssSelectorEvaluator.CSS_SELECTOR_TEMPLATE
谁能告诉我两者的用处更多?
提前致谢
Can anyone tell me more usefulness of both?
Thanks in advance
推荐答案
请参阅此中的答案3链接 [ ^ ]
这篇关于Const和Static之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文