小编use*_*317的帖子

为什么不公开所有字段/属性/方法?

我知道这可能听起来很愚蠢,但我真的很想知道:)我正在学习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
Run Code Online (Sandbox Code Playgroud)

那么以其他形式使其无法达到的重点是什么?为什么每件事都不公开或默认不公开?

谢谢.

c# oop information-hiding access-modifiers public-members

1
推荐指数
2
解决办法
1145
查看次数

Math-pow结果不正确

            double a1;
        a1 = Math.Pow(somehighnumber, 40);
        something.Text = Convert.ToString(xyz);
Run Code Online (Sandbox Code Playgroud)

我得到的结果是E + 41等,它像1,125123E + 41等我不明白为什么.

c# math floating-point

-8
推荐指数
2
解决办法
1123
查看次数