隐藏等于和参考平等? [英] Hiding Equals and ReferenceEquals?

查看:67
本文介绍了隐藏等于和参考平等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在dotnet.languages.vc小组上发布了这个,但没有得到

回复。我认为我可以将我从CSharp学到的知识应用到VC,

所以这里有。


我有一个类集合中的类,它只是一堆静态

方法。如何从我的最终用户程序员隐藏Equals和ReferenceEquals属性



-

Bruce E. Stemplewski

用于Garmin GPS的GarXface OCX和C ++类库
www.stempsoft.com

解决方案

" Bruce" < Br *** @nospam.comaécritdansle message de news:
OO ************** @ TK2MSFTNGP06.phx.gbl ...


|我在类汇编中有一个类,它只有一堆静态

|方法。如何隐藏Equals和ReferenceEquals属性

|来自我的最终用户程序员?


任何标记为公共的东西都不能从那个

类的其他用户隐藏。隐藏某些东西的唯一方法是将其标记为私有,受保护或

内部,具体取决于所需的隐藏程度。


Joanna


-

Joanna Carter [TeamB]

顾问软件工程师


Joanna Carter [TeamB]写道:


" Bruce" < Br *** @nospam.comaécritdansle message de news:
OO ************** @ TK2MSFTNGP06.phx.gbl ...


|我在类汇编中有一个类,它只有一堆静态

|方法。如何隐藏Equals和ReferenceEquals属性

|来自我的最终用户程序员?


任何标记为公共的东西都不能从那个

类的其他用户隐藏。隐藏某些东西的唯一方法是将其标记为私有,受保护或

内部,具体取决于所需的隐藏程度。


Joanna



有没有办法从Object

以外的东西派生我的课程呢? Microsoft如何使用Microsoft.VisualBasic.ChDir()为

示例执行此操作?我认为VisualBasic是一个名称空间?如果是这样的话,他们如何出售Chdir
出售Chdir,不是必须成为班级的一员吗?

-

布鲁斯E. Stemplewski

用于Garmin GPS的GarXface OCX和C ++类库
www.stempsoft.com


" Bruce" < Br *** @nospam.comaécritdansle message de news:

%2*************** @ TK2MSFTNGP04.phx.gbl .. 。


|有没有办法从Object

|以外的东西派生我的课程那么?


不,所有.NET类型都派生自System.Object。


| Microsoft如何使用Microsoft.VisualBasic.ChDir()为

|执行此操作例?我认为VisualBasic是一个名称空间?如果是这样,他们如何

|导出Chdir,它不是必须成为类的一部分吗?


ChDir是DLL中的非托管函数,它不是.NET的一部分

框架类。 VB似乎与C#略有不同,因为它允许

模块函数与类无关。就我个人而言,我认为这会造成混乱,并且很可能只有原有的兼容性。


你想要实现的目标是什么?为什么? >

Joanna


-

Joanna Carter [TeamB]

顾问软件工程师

I posted this on the dotnet.languages.vc group but did not get a
response. I figure that I could apply what I learn from CSharp to VC,
so here goes.

I have a class in a class assembly, that just has a bunch of static
methods. How can I hide the Equals and ReferenceEquals properties
from my end user programmer?
--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com

解决方案

"Bruce" <Br***@nospam.coma écrit dans le message de news:
OO**************@TK2MSFTNGP06.phx.gbl...

| I have a class in a class assembly, that just has a bunch of static
| methods. How can I hide the Equals and ReferenceEquals properties
| from my end user programmer?

Anything that is marked public cannot be hidden from other users of that
class. The only way to hide something is to mark it as private, protected or
internal, depending on the degreee of hiding desired.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


Joanna Carter [TeamB] wrote:

"Bruce" <Br***@nospam.coma écrit dans le message de news:
OO**************@TK2MSFTNGP06.phx.gbl...

| I have a class in a class assembly, that just has a bunch of static
| methods. How can I hide the Equals and ReferenceEquals properties
| from my end user programmer?

Anything that is marked public cannot be hidden from other users of that
class. The only way to hide something is to mark it as private, protected or
internal, depending on the degreee of hiding desired.

Joanna


Is there any way to derive my class from something other than Object
then? How does Microsoft do it with Microsoft.VisualBasic.ChDir() for
example? I take it VisualBasic is a namespace? If so, how do they
export Chdir, doesn''t it have to be a part of a class?
--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com


"Bruce" <Br***@nospam.coma écrit dans le message de news:
%2***************@TK2MSFTNGP04.phx.gbl...

| Is there any way to derive my class from something other than Object
| then?

No, all .NET types derive from System.Object.

| How does Microsoft do it with Microsoft.VisualBasic.ChDir() for
| example? I take it VisualBasic is a namespace? If so, how do they
| export Chdir, doesn''t it have to be a part of a class?

ChDir is an unmanaged function in a DLL, it is not part of the .NET
framework classes. VB seems to be a bit different from C# in that it allows
module functions unconnected with classes. Personally, I think this causes
confusion and is more than likely there only for legacy compatibility.

What are you trying to achieve and why ?

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


这篇关于隐藏等于和参考平等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆