且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

具有不同访问者的属性?

更新时间:2023-12-03 09:45:52

是否可以创建一个设置属性具有与获取属性不同的可访问性?
Is it possible to create a set property which has a different accessibility
than the get property?




编号但它是未来版本的常用功能。


Mattias


-

Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/

请回复新闻组。



No. But it''s a commonly requested feature for future versions.

Mattias

--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.


数字;(


我猜***解决方法是将属性作为

hoi-polloi的只读属性,然后对派生类有一个受保护的方法,但是

似乎都是这可能是一件非常简单的事情。


感谢您的快速回复,


你的,>

Ann-Marie Ratcliffe


PS如果有一种比我上面提到的更简洁的方式,我很乐意听到它。



" Mattias Sj?gren" <毫安******************** @ mvps.org>在消息中写道

新闻:OQ ************* @ TK2MSFTNGP11.phx.gbl ...
Figures ;(

I guess the best work-around is to have the Property as read-only for the
hoi-polloi, and then have a protected Method for the derived classes, but it
all seems like a two''n''eight for what could be so simple.

Thanks for your quick reply,

Yours,

Ann-Marie Ratcliffe

P.S. If there is a neater way than I''ve suggested above I''d love to hear it.


"Mattias Sj?gren" <ma********************@mvps.org> wrote in message
news:OQ*************@TK2MSFTNGP11.phx.gbl...
是否可以创建一个具有与get属性不同的
可访问性的set属性?
Is it possible to create a set property which has a different accessibilitythan the get property?



否。但它是未来版本的常用功能。

Mattias

- Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
请仅回复新闻组。



No. But it''s a commonly requested feature for future versions.

Mattias

--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.



A Ratcliffe< ar ******** @ archiNOSPAMmagic.net>写道:
A Ratcliffe <ar********@archiNOSPAMmagic.net> wrote:
我想***的解决方法是将属性作为
hoi-polloi的只读,然后对派生类有一个受保护的方法,但它
I guess the best work-around is to have the Property as read-only for the
hoi-polloi, and then have a protected Method for the derived classes, but it
all seems like a two''n''eight for what could be so simple.




是的,这很痛苦 - 坦白说,我我很惊讶它是在v1.0之前没有得到的b $ b固定的。这似乎是一件显而易见的事情......

也许有些问题我不知道。


一个只读属性和一个mutator方法,反之亦然

(私有财产,公共访问者),或者只是有两种方法

目前确实是选项。


幸运的是,不仅要求下一个版本,而且

显然也会发生这种情况:)


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复该群组,请不要给我发邮件



Yes, it''s a pain - and frankly, I''m surprised it''s one which didn''t get
fixed before v1.0. It seems such an obvious thing to want to do...
maybe there are problems with it that I''m not aware of.

Having either a readonly property and a mutator method, or vice versa
(private property, public accessor), or just having two methods are
indeed the options at the moment.

Fortunately, not only has this been requested for the next version, but
apparently it''s going to happen, too :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too