Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How VB.NET uses Sorted Lists

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to use VB.NET Sorted Lists, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Visual Basic.NET is an object-oriented intermediate interpretive language based on Microsoft. NET Framework, which can be regarded as an upgraded version of Visual Basic on the .net Framework platform, which enhances the support for object-oriented. However, because the change is too big, the backward compatibility of VB.net to VB is not good, which causes a lot of controversy in the industry.

Most VB.Net programmers use Visual Studio. Net as IDE (integrated development environment). SharpDevelop is another available open source IDE. VB.Net needs to be executed on the .net Framework platform.

Advantages and disadvantages of SortedList

System.Collections.SortedList is a dictionary type based on key values that allows entries to be stored in a certain order. This has a great advantage in dealing with content that is already in order. The convenience of SortedList is that it pays less addition cost and less deletion cost. SortedList uses two arrays: one to store key values and the other to store data or object references.

When VB.NET uses Sorted Lists, keep in mind that objects are stored based on keys rather than objects; therefore, keys need to support IComparable, that is, integers or characters. Otherwise, when defining a SortedList, customize an IComparer as a parameter to the SortedList.

Example

In the Listing A code example, I define a new instance of the SortedList class: srtList, as well as a DictionaryEntry to hold special entries, which is stored in SortedList. Then I added three entries to the list using the add method.

Note: the entry I added is a _ c _ c, and its key value is 1pm _ 3pm _ 2. This is to show that the entry is immediately stored in SortedList and stored with its key value. To determine this, I created a loop to iterate through all the entries in the srtList and display their key and value in turn. As expected, the results are as follows: key value: 1; value: a; key value: 2; value: C, key value: 3; value: b.

The above is all the content of the article "how VB.NET uses Sorted Lists". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report