using UnityEngine;

using System.Collections;


class Item{

public int no;

public string name;

public int price;

}


public class chap10_10 : MonoBehaviour {


// Use this for initialization

void Start () {

Hashtable ht = new Hashtable();

Item a = new Item();

//string text = "2014    Asian Game 2014 World Cup " + " 2014 LOL Game Asian Cup";

string[] ItemList = {"1, HP POTION LV1, 1000", "2, MP POTION LV1, 1000",

    "3, HP POTION LV2, 5000", "3, MP POTION LV2, 5000"} ;

char[] sep = {','} ;

foreach(string data in ItemList){

print (data);

string[] tokens = data.Split(sep);

//print(tokens[0]);

//print(tokens[1]);

//print(tokens[2]);

Item item = new Item();

item.no = int.Parse(tokens[0]);

item.name = tokens[1];

item.price = int.Parse(tokens[2]);

ht[item.no] = item;

}

Item item1 = ht[1] as Item;

if(ht.ContainsKey(1))

item1 = (Item)ht[1];

if(ht.ContainsValue(item1))

print ("item1 Exist");

foreach(Item item in ht.Values){

print (string.Format("Item[{0}] = [{1}], price = {2} ", item.no, item.name, item.price));

}

}

// Update is called once per frame

void Update () {

}

}



+ Recent posts