1.1. C#中的字典类型变量

C#中也有类似于Python中的字典类型的变量

参考代码如下:


Dictionary<String, int> dicPicIdx;
Dictionary<string, int>.KeyCollection dicKeys;
 
dicPicIdx = new Dictionary<string, int>();
dicPicIdx.Add("EmptyDocumentFolder", 1);
dicPicIdx.Add("NonEmptyDocumentFolder", 1);
 
dicPicIdx.Add("NonEmptyAlbum", 3);
dicPicIdx.Add("EmptyAlbum", 3);
 
dicPicIdx.Add("NonEmptyFavoriteFolder", 4);
dicPicIdx.Add("EmptyFavoriteFolder", 4);
 
dicPicIdx.Add("Photo", 6);
dicPicIdx.Add("Audio", 7);
dicPicIdx.Add("Video", 8);
 
dicKeys = dicPicIdx.Keys;