Get the App
SLTechnology News&Howtos  ›  Development  › 

How VB.NET uses Sorted Lists

Shulou Source: shulou.com Published: 2022-06-02 18:38:35 09月22日 Update

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!

Tags: Items storage objects content articles cost platform order reference support character type special not good not so good industry two code advantages advantages compatibility Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Microsoft Xiaomi Apple Redmi