avatar
[转载] A C# question# DotNet - 窗口里的风景
s*i
1
【 以下文字转载自 Programming 讨论区,原文如下 】
发信人: sui ()(), 信区: Programming
标 题: A C# question
发信站: Unknown Space - 未名空间 (Wed May 19 11:28:39 2004) WWW-POST
I have two class A and B. I want to make a method in A public only to B. Is
this possible? How to implement? Thanks.
avatar
k*i
2
Make it internal and only put A and B in one assembly

【在 s*i 的大作中提到】
: 【 以下文字转载自 Programming 讨论区,原文如下 】
: 发信人: sui ()(), 信区: Programming
: 标 题: A C# question
: 发信站: Unknown Space - 未名空间 (Wed May 19 11:28:39 2004) WWW-POST
: I have two class A and B. I want to make a method in A public only to B. Is
: this possible? How to implement? Thanks.

avatar
m*n
3
make the method protected and then inherit B from A.

Is

【在 k****i 的大作中提到】
: Make it internal and only put A and B in one assembly
avatar
k*i
4
It's still accessible for other descendant classes of A though

【在 m*******n 的大作中提到】
: make the method protected and then inherit B from A.
:
: Is

avatar
m*n
5
your approach is less extensible. my approach is under-standard but should be
okay for most cases. right?

B.

【在 k****i 的大作中提到】
: It's still accessible for other descendant classes of A though
avatar
k*i
6
Depends on his need.
Looks like he don't want ANY other classes except B to access A's function.

be
to

【在 m*******n 的大作中提到】
: your approach is less extensible. my approach is under-standard but should be
: okay for most cases. right?
:
: B.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。