【发布时间】:2011-07-09 19:02:42
【问题描述】:
我知道这听起来可能很愚蠢,但我真的很想知道 :) 我正在学习c#,
如您所知,您需要将“对象”(按钮、标签、文本、变量等)设置为公开或任何您喜欢的。
但是,你仍然需要编写这样的代码:
// my point is you cant just type label1.text you need to type class.label1.text
// so there is no chance of getting bugged
//because there is label1 in each of forms/classes
class Classlol = new class();
classlol.label1.blabla
那么以其他形式使其无法访问有什么意义呢?为什么每件事都不公开或默认不公开?
谢谢。
【问题讨论】:
-
当您说
object时,您是指member还是class? -
“我的意思是你不能只输入 label1.text,你需要输入 class.label1.text,这样就不会被窃听,因为每个表单/类中都有 label1”。什么?
标签: c# oop access-modifiers information-hiding public-members