VB.NET中的Readonly属性 [英] Readonly property in VB.NET

查看:893
本文介绍了VB.NET中的Readonly属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我是VB开发人员,现在我已经转到VB.NET了。我很少有人怀疑这很容易做VB 6.0而不是VB.NET。



1.如何在属性窗口导航?

是否有任何短按键可以在属性窗口中导航。

例如。在VB 6.0中,我选择一个控件并按F4打开属性窗口,它在VB.NET中也是如此,但在VB 6.0中我们可以通过按Ctrl + Shift +(属性的初始字符)导航到任何属性。对于前者如果我必须在VB 6.0中转到它的名称属性,我将按Ctrl + Shift + N,它将移动到控件的Name属性。



2。 VB.NET中readonly关键字需要创建一个只读属性,如VB 6.0中我们可以创建只读属性而不是给setter(Set)只有getter(Get)?



我用谷歌搜索但找不到满意的结果。



谢谢,

Sukhen Dass

Hi All,

I am a VB developer and now I have moved to VB.NET. I have few doubts which was easy to do VB 6.0 but not in VB.NET.

1. How to navigate in the property window?
Is there any short key to navigate in the property window.
For ex. in VB 6.0 I select a control and press F4 it opens the property window it happens the same in VB.NET as well, but in VB 6.0 we can navigate to any property by pressing Ctrl+Shift+(Initial Character of the property). For ex. If I have to go to its name property in VB 6.0 I will press Ctrl+Shift+N and it will move to the Name property of the control.

2. What is the need of "readonly" keyword in VB.NET to create a read only property as in VB 6.0 we can create read only property not to give the setter(Set) only getter(Get)?

I Googled but could not find a satisfactory result.

Thanks,
Sukhen Dass

推荐答案

1。快捷键仍然是F4,但可能取决于您的设置(学习使用Visual Studio,它与VB无关)。

2. ReadOnly关键字 [ ^ ]。我没有太多考虑过它(你也不应该接受它),但我喜欢它,因为它显示了IntelliSense属性是ReadOnly(具有私有Setter的常规属性不会完成同样的事情)。但是,如果我必须做出猜测,为什么它是绝对必要的,我猜它会让你的编译器知道它不必为指定的属性创建一个Setter(IL不会创建一个set_Property方法)。性能可能更好。对于WriteOnly属性也是如此。
1. The shortcut key is still F4, but may depend on your settings (learn to use Visual Studio, it has nothing to do with VB).
2. The ReadOnly keyword[^]. I haven't given much thought to it (and neither should you, just accept it), but I like it because it shows IntelliSense that a Property is ReadOnly (having a regular Property with a Private Setter does not accomplish the same thing). But if I had to make a guess as to why it is absolutely necessary I'd guess it lets your compiler know that it does not have to create a Setter for the specified Property (IL does not create a set_Property Method). Might be better for performace. Same for WriteOnly Properties.


这篇关于VB.NET中的Readonly属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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