ASP Dictionary Object
Dictionary object သည် အချက်အလက်များကို အမည်/တန်ဖိုးအတွဲများဖြင့် သိမ်းဆည်းထားသည်။
နောက်ထပ် ဥပမာများ
Dictionary object တစ်ခုကို ဖန်တီးနည်း၊ ထို့နောက် သတ်မှတ်ထားသော သော့ရှိမရှိ စစ်ဆေးရန် Exists နည်းလမ်းကို အသုံးပြုပါ။
ခင်းကျင်းတစ်ခုပြန်ပို့ပေးရန် Items နည်းလမ်းကို အသုံးပြုနည်း။
တစ်ခုကို ပြန်ရန် သော့နည်းလမ်းကို အသုံးပြုနည်း။
တစ်ခု၏တန်ဖိုးကို ပြန်ပေးသည့်အရာသည် အရာတစ်ခု၏တန်ဖိုးကို ပြန်ပေးရန်အတွက် Item Property ကိုအသုံးပြုနည်း။
သော့ပိုင်ဆိုင်မှုကို အသုံးပြုနည်း Dictionary object တစ်ခုတွင် သော့တစ်ခုကို သတ်မှတ်ရန်။
များ အရေအတွက်ကို ပြန်ပေးရန်အတွက် Count property ကို အသုံးပြုနည်း။
Dictionary Object
Dictionary object ကို အမည်/တန်ဖိုးအတွဲများ (သော့နှင့် အကြောင်းအရာဟု ရည်ညွှန်းသည်) တွင် အချက်အလက်များကို သိမ်းဆည်းရန်အတွက် အသုံးပြုပါသည်။ Dictionary object သည် Arrays နှင့် ဆင်တူပုံရနိုင်သော်လည်း Dictionary object သည် ဆက်စပ်ဒေတာများကို ကိုင်တွယ်ရန် ပို၍နှစ်လိုဖွယ်ကောင်းသော အဖြေတစ်ခုဖြစ်သည်။
အဘိဓာန်များနှင့် အခင်းအကျင်းများကို နှိုင်းယှဉ်ခြင်း-
- Dictionary object တစ်ခုရှိ အရာများကို ခွဲခြားသတ်မှတ်ရန် သော့များကို အသုံးပြုသည်။
- Dictionary object ၏ အရွယ်အစားကို ပြောင်းလဲရန် ReDim ကို သင်ခေါ်ဆိုရန် မလိုအပ်ပါ။
- Dictionary တစ်ခုမှ အကြောင်းအရာတစ်ခုကို ဖျက်လိုက်သောအခါ ကျန်အရာများသည် အလိုအလျောက် ပြောင်းသွားပါမည်။
- အဘိဓာန်များသည် ဘက်ပေါင်းစုံမှမဖြစ်နိုင်ပါ၊ Array များလုပ်နိုင်သည်။
- အဘိဓာန်များသည် Arrays များထက် built-in function ပိုများသည်။
- အဘိဓာန်များသည် ကျပန်းဒြပ်စင်များကို မကြာခဏဝင်ရောက်ကြည့်ရှုခြင်းအတွက် array များထက် ပိုမိုကောင်းမွန်ပါသည်။
- အဘိဓာန်များသည် ၎င်းတို့၏ အကြောင်းအရာအလိုက် အရာများကို ရှာဖွေရာတွင် အခင်းအကျင်းများထက် ပိုမိုကောင်းမွန်ပါသည်။
အောက်ဖော်ပြပါ ဥပမာသည် Dictionary object တစ်ခုကို ဖန်တီးပြီး၊ အချို့သော့/ပစ္စည်း အတွဲများကို ၎င်းသို့ ပေါင်းထည့်ကာ key gr အတွက် item value ကို ပြန်လည်ရယူသည်-
<%
Dim d
Set d=Server.CreateObject("Scripting.Dictionary")
d.Add "re","Red"
d.Add "gr","Green"
d.Add "bl","Blue"
d.Add "pi","Pink"
Response.Write("The value of key gr is: " & d.Item("gr"))
%>
Output:
The value of key gr is: Green
Dictionary object ၏ ဂုဏ်သတ္တိများနှင့် နည်းလမ်းများကို အောက်တွင် ဖော်ပြထားပါသည်။
သတ္တိ
Property | Description |
---|---|
CompareMode | Sets or returns the comparison mode for comparing keys in a Dictionary object |
Count | Returns the number of key/item pairs in a Dictionary object |
Item | Sets or returns the value of an item in a Dictionary object |
Key | Sets a new key value for an existing key value in a Dictionary object |
နည်းလမ်းများ
Method | Description |
---|---|
Add | Adds a new key/item pair to a Dictionary object |
Exists | Returns a Boolean value that indicates whether a specified key exists in the Dictionary object |
Items | Returns an array of all the items in a Dictionary object |
Keys | Returns an array of all the keys in a Dictionary object |
Remove | Removes one specified key/item pair from the Dictionary object |
RemoveAll | Removes all the key/item pairs in the Dictionary object |