由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DotNet版 - VB.Net question
相关主题
.net 2003竟然不支持类中静态变量如果编程语言是车的话 (转载)
NUNIT and NUNIT add-in问问学计算机的同学、家长们,现在还有人学PASCAL吗 (转载)
Java里面有没有可能写个带generic parameter的class对built-in type也适用?微软的SDE居然不需要会C++ 和 data structure!? (转载)
Sun当年设计Java的败笔求问,英文不好的超级码工可以找到工作么?
c++这种语言注定了会越做越小天天泡网是不是很可怜?
如果编程语言是车的话和一位铁杆果轮度过了愉快的一上午 (转载)
Got an offer[Mac Dev]整了个ObjectiveC的笔记,看看气氛对得上不
关于程序设计语言的讨论:通天塔导游请教个问题:Apple为什么抓着Objective C不放?
相关话题的讨论汇总
话题: private话题: class话题: access话题: c#话题: public
进入DotNet版参与讨论
1 (共1页)
g****y
发帖数: 212
1
In Class A, I have several private data memebers,
in one public function of A, I take another object B of type A as parameter.
Why can I access B's private member?
For example
public class A
private a1 as Integer
private b1 as Interger
public sub test(byval B as A)
me.a1 = B.a1
~~~~~~
end sub
End class
p***n
发帖数: 635
2
it is probably a BUG in the framework or it is "By Design"

【在 g****y 的大作中提到】
: In Class A, I have several private data memebers,
: in one public function of A, I take another object B of type A as parameter.
: Why can I access B's private member?
: For example
: public class A
: private a1 as Integer
: private b1 as Interger
: public sub test(byval B as A)
: me.a1 = B.a1
: ~~~~~~

g****y
发帖数: 212
3
If it is true.
How can you expect the MSIL code of VB.net and C#.net could be the same?
I assume that c# doesn't have such problem.

parameter.

【在 p***n 的大作中提到】
: it is probably a BUG in the framework or it is "By Design"
d******p
发帖数: 24
4
It is called class-based "private".
It is true for all c++ family language, including
java and C#. While Smalltalk supports what you
what, object-based "private".
BTW, "protected" is different.

【在 g****y 的大作中提到】
: If it is true.
: How can you expect the MSIL code of VB.net and C#.net could be the same?
: I assume that c# doesn't have such problem.
:
: parameter.

s*i
发帖数: 5025
5
In C#, you will get the same thing.
I think it is a good thing. By default, the "producer" of class A, who is the
programmer, has all the power to design, implement anything related to A. So
when he is implementing something related to A, he should be able to access
anything.
However, the "consumer", other classes that uses A, should have restricted
access power.
Any senario that this could be a really bad idea?

【在 g****y 的大作中提到】
: If it is true.
: How can you expect the MSIL code of VB.net and C#.net could be the same?
: I assume that c# doesn't have such problem.
:
: parameter.

g****y
发帖数: 212
6
en. That means, if I want, I could make the objects of same type access each
other's private member ?
I don't think it is true in C++ or Java.

the

【在 s*i 的大作中提到】
: In C#, you will get the same thing.
: I think it is a good thing. By default, the "producer" of class A, who is the
: programmer, has all the power to design, implement anything related to A. So
: when he is implementing something related to A, he should be able to access
: anything.
: However, the "consumer", other classes that uses A, should have restricted
: access power.
: Any senario that this could be a really bad idea?

s*i
发帖数: 5025
7
Only when you are writing code within class A{} scope, you can do that. I am
not sure about Java and C++.

So
access

【在 g****y 的大作中提到】
: en. That means, if I want, I could make the objects of same type access each
: other's private member ?
: I don't think it is true in C++ or Java.
:
: the

g****y
发帖数: 212
8
en. That means, if I want, I could make the objects of same type access each
other's private member ?
I don't think it is true in C++ or Java.

【在 d******p 的大作中提到】
: It is called class-based "private".
: It is true for all c++ family language, including
: java and C#. While Smalltalk supports what you
: what, object-based "private".
: BTW, "protected" is different.

g****y
发帖数: 212
9
Thanks.

each
is
A.
restricted
same?

【在 s*i 的大作中提到】
: Only when you are writing code within class A{} scope, you can do that. I am
: not sure about Java and C++.
:
: So
: access

1 (共1页)
进入DotNet版参与讨论
相关主题
请教个问题:Apple为什么抓着Objective C不放?c++这种语言注定了会越做越小
还是我来给大家讲讲PC/Mac及其它如果编程语言是车的话
和一位铁杆果轮度过了愉快的一上午 (转载)Got an offer
其实cook还是很厉害的关于程序设计语言的讨论:通天塔导游
.net 2003竟然不支持类中静态变量如果编程语言是车的话 (转载)
NUNIT and NUNIT add-in问问学计算机的同学、家长们,现在还有人学PASCAL吗 (转载)
Java里面有没有可能写个带generic parameter的class对built-in type也适用?微软的SDE居然不需要会C++ 和 data structure!? (转载)
Sun当年设计Java的败笔求问,英文不好的超级码工可以找到工作么?
相关话题的讨论汇总
话题: private话题: class话题: access话题: c#话题: public