公共获取和朋友设置的属性? [英] Property with Public Get and Friend Set?

查看:53
本文介绍了公共获取和朋友设置的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个属性,我希望GET可用于任何人(即公共)
;但是,我希望SET只能用于

类或程序本身(即朋友)。


在VB6中这很容易,因为获取和集是分开的。如何用VB.NET做这个?b / b
Tom

解决方案

< blockquote> *汤姆 < to*@nospam.com> scripsit:

我写了一个属性,我想让GET可供任何人使用(即公开);但是,我希望SET只能用于
类或程序本身(即朋友)。

在VB6中,这很容易,因为获取和集合是分开的。如何在VB.NET中实现这一点?




你必须编写单独的_procedures_,例如''GetFoo''

函数和''SetFoo''子。


-

Herfried K. Wagner

MVP· VB Classic,VB.NET

< http://www.mvps.org/dotnet>


" Tom" < to*@nospam.com> schrieb

我写了一个属性,我希望任何人都可以获得GET(即公开);但是,我希望SET只能在类或程序本身(即朋友)上使用。

在VB6中,这很容易,因为获取和集合是分开的。如何在VB.NET中做到这一点?




不幸的是,这在VB.NET中是不可能的。你必须写一个

Set程序和一个Get程序来单独指定修饰符。

-

Armin


嗨Tom,


我知道的唯一方法需要很多耐心。你向

VB.NET开发团队提交了一个愿望,并让你所有的朋友,亲戚,邻居等等。

来做同样的事情。然后你等待它在将来的版本中出现。


我也喜欢它,或者更确切地说是私人/受保护的集合和公共获取。

问候,

Fergus


I have written a property, where I want to have the GET be available to
anyone (i.e. Public); however, I want the SET to be available ONLY to the
class or program itself (i.e. Friend).

In VB6 this was easy, since the Gets and Sets were seperate. How can one do
this in VB.NET?

Tom

解决方案

* "Tom" <to*@nospam.com> scripsit:

I have written a property, where I want to have the GET be available to
anyone (i.e. Public); however, I want the SET to be available ONLY to the
class or program itself (i.e. Friend).

In VB6 this was easy, since the Gets and Sets were seperate. How can one do
this in VB.NET?



You will have to write separate _procedures_, for example a ''GetFoo''
function and a ''SetFoo'' sub.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>


"Tom" <to*@nospam.com> schrieb

I have written a property, where I want to have the GET be available
to anyone (i.e. Public); however, I want the SET to be available ONLY
to the class or program itself (i.e. Friend).

In VB6 this was easy, since the Gets and Sets were seperate. How can
one do this in VB.NET?



Unfortunatelly, this is not possible in VB.NET. You would have to write a
Set procedure and a Get procedure to individually specify the modifier.
--
Armin


Hi Tom,

The only way that I know takes a lot of patience. You submit a wish to the
VB.NET development team and get all your friends, relatives, neighbours, etc
to do the same. Then you wait for it to come out in a future version.

I''d like it too, or rather Private/Protected Set and Public Get.

Regards,
Fergus


这篇关于公共获取和朋友设置的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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