In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the content of the C # Dictionary generic collection". In the daily operation, I believe that many people have doubts about the content of the C # Dictionary generic collection. The editor consulted all kinds of materials and sorted out a simple and useful method of operation. I hope it will be helpful for you to answer the question of "what is the content of the C # Dictionary generic collection?" Next, please follow the editor to study!
C # generic collection is the most common use of generics. The namespace System.Collections.Generic contains some generic collection classes. Dictionary generic collection is one of the C # generic collections. Using generic collection classes can provide higher type safety and higher performance, avoiding repeated boxing and unboxing of non-generic collections. Many non-generic collection classes have corresponding generic collection classes, commonly used non-generic collection classes, and corresponding generic collection classes:
C # correspondence between non-generic collection classes of generic collections and generic collection classes:
ArrayList corresponds to List
HashTable corresponds to Dictionary
Queue corresponds to Queue
Stack corresponds to Stack
SortedList corresponds to SortedList
The most common non-generic collection classes we use are ArrayList class and HashTable class. We often use HashTable to store the information to be written to or returned to the database, which requires continuous type conversion, which increases the burden of packing and unpacking the system. It is much more convenient if the data types we manipulate are relatively certain to use Dictionary collection classes to store data, for example, when we need to store users' shopping cart information (product name, corresponding number of items) in e-commerce websites. You can use Dictionary to store shopping cart information without any type conversion.
The following is a simple example of a Dictionary generic collection, including declaring, populating key-value pairs, removing key-value pairs, and traversing key-value pairs
Dictionary < string,string > myDic=newDictionary < string,string > (); myDic.Add ("aaa"); myDic.Add ("bbb", "222"); myDic.Add ("ccc", "333"); myDic.Add ("ddd", "444"); / / if an existing key is added, the add method throws an exception try {myDic.Add ("ddd", "ddd"). } catch (ArgumentExceptionex) at this point, the study on "what is the content of the C # Dictionary generics collection" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.