In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "simple description of VB.NET default properties", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "simple description of VB.NET default properties" bar!
Before giving you a detailed introduction to the default properties of VB.NET, let you first understand that the default property of TextBox is Text, and then give a comprehensive introduction to the default properties of VB.NET. In the original VB6, there was a strange feature-default properties. In VB6, the name of an object can directly represent the default properties of that object. For example, the default property of TextBox is Text, so the following code
Text1.Text = "Hello"
It can be reduced to
Text1 = "Hello"
This simplification brings a lot of trouble to VB. The assignment operation requires two keywords-Let and Set, and the result attribute process also needs Let and Set. And this feature still works during late binding. When it comes to VB.NET, this functionality is so limited that only properties with parameters can now be used as default properties. Such as
List1.Item (0) = "Hello"
Can be reduced to
List1 (0) = "Hello"
This syntax makes objects with default properties look like an array. So how does VB determine whether an attribute is the default? Look at the following code
Public Class PropTest Public Property P1 (ByVal index As Integer) As String Get End Get Set (ByVal Value As String) End Set End Property Default Public Property P2 (ByVal index As Integer) As String Get End Get Set (ByVal Value As String) End Set End Property End Class
The attributes P1 and P2 are basically the same, but the difference between * is that P2 has a Default modifier. After disassembling this class, you can find that the two properties are exactly the same without any difference. However, the PropTest class has been added with a custom meta-attribute System.Reflection.DefaultMemberAttribute. The member specified by this meta property is the default type used by InvokeMember, which means that late binding can also use the default property. However, I tried to manually add the DefaultMember meta-attribute to the type, but did not achieve the function of making a property the default attribute. It seems that this feature is another "grammatical sweetness" of VB. However, the compiler of VB or C # should only judge the default properties of classes generated by others by DefaultMemberAttribute, so I specify a default method for a VB class with DefaultMemberAttribute instead of Default, and then compile it for use by C #. Sure enough, C # recognizes it as an indexer!
Thank you for your reading, the above is the content of "simply explain the default properties of VB.NET". After the study of this article, I believe you have a deeper understanding of the problem of simply explaining the default properties of VB.NET, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.