New dictionary

Jmnote (토론 | 기여)님의 2013년 10월 27일 (일) 20:31 판 (새 문서: category: dictionary ;Associative arrays ;hash map ;hash table ;Dictionary ;NSDictionary ;NSMutableDictionary ==Bash== category: bash <source lang='bash'> declare -A DICT DIC...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)
Associative arrays
hash map
hash table
Dictionary
NSDictionary
NSMutableDictionary

1 Bash

declare -A DICT
DICT["ID"]=102
DICT["Name"]="YONEZAWA Akinori"
DICT["Address"]="Naha, Okinawa"

2 C#

Hashtable ht = new Hashtable();
ht.Add("ID", "102");
ht.Add("Name", "YONEZAWA Akinori");
ht.Add("Address", "Naha, Okinawa");
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("ID", "102");
dic.Add("Name", "YONEZAWA Akinori");
dic.Add("Address", "Naha, Okinawa");
Dictionary<int, string> = new Dictionary<int, string> {
  { "ID", "102" },
  { "Name", "YONEZAWA Akinori" },
  { "Address", "Naha, Okinawa" }
};

3 Java

HashMap<String,Object> map = new HashMap<String,Object>();
map.put("ID", "102");
map.put("Name", "YONEZAWA Akinori");
map.put("Address", "Naha, Okinawa");
System.out.print("map", map.toString());
// {Name=YONEZAWA Akinori, ID=102, Address=Naha, Okinawa}

4 JavaScript

var dic = new Object();
dic['ID'] = "102";
dic['Name'] = "YONEZAWA Akinori";
dic['Address'] = "Naha, Okinawa";
console.log(dic);
// Object {ID: "102", Name: "YONEZAWA Akinori", Address: "Naha, Okinawa"}

5 Objective-C

NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
[dic setObject:@"102" forKey:@"ID"];
[dic setObject:@"YONEZAWA Akinori" forKey:@"Name"];
[dic setObject:@"Naha, Okinawa" forKey:@"Address"];

6 PHP

$dict = array(
  "ID" => 102,
  "Name" => "YONEZAWA Akinori",
  "Address"=> "Naha, Okinawa"
);

7 See also

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}