Click here to Skip to main content
15,888,610 members
Home / Discussions / C#
   

C#

 
QuestionHow to remove the Highlight blue colour in list box Pin
Joe Rozario18-Mar-10 18:32
Joe Rozario18-Mar-10 18:32 
AnswerRe: How to remove the Highlight blue colour in list box Pin
Joe Rozario18-Mar-10 19:47
Joe Rozario18-Mar-10 19:47 
QuestionUsing textfile as a storage system for numerical data... Pin
sebogawa18-Mar-10 16:34
sebogawa18-Mar-10 16:34 
AnswerRe: Using textfile as Pin
RCoate18-Mar-10 16:40
RCoate18-Mar-10 16:40 
GeneralRe: Using textfile as Pin
sebogawa18-Mar-10 16:45
sebogawa18-Mar-10 16:45 
AnswerRe: Using textfile as a storage system for numerical data... Pin
Luc Pattyn18-Mar-10 16:51
sitebuilderLuc Pattyn18-Mar-10 16:51 
GeneralRe: Using textfile as a storage system for numerical data... Pin
sebogawa18-Mar-10 17:28
sebogawa18-Mar-10 17:28 
GeneralRe: Using textfile as a storage system for numerical data... Pin
Luc Pattyn18-Mar-10 17:38
sitebuilderLuc Pattyn18-Mar-10 17:38 
You create the dictionary like so (omitting error handling):
Dictionary<string, string> dict=new Dictionary<string, string>();
foreach(string s in File.ReadAllLines(path)) {
    string parts[]=string.Split('=', 2);
    dict.Remove(parts[0]);   // remove if it already exists
    dict.Add(parts[0], parts[1]);
}


You look up a key's value by using the key as an index to your dictionary, like so:
string name=dict["Name"];


You enumerate all key-values (maybe not in original order!) like so:
foreach (KeyValuePair<string, string> kvp in dict) {
	log(kvp.Key+"="+kvp.Value);
}


You could also prepopulate the dictionary with default values for some keys:
dict.Add("Name", "Jef");
dict.Add("Occupation", "Software Engineer");


Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.

GeneralRe: Using textfile as a storage system for numerical data... Pin
sebogawa18-Mar-10 17:50
sebogawa18-Mar-10 17:50 
GeneralRe: Using textfile as a storage system for numerical data... Pin
sebogawa18-Mar-10 22:43
sebogawa18-Mar-10 22:43 
GeneralRe: Using textfile as a storage system for numerical data... Pin
Luc Pattyn19-Mar-10 3:03
sitebuilderLuc Pattyn19-Mar-10 3:03 
QuestionMicrosoft.Exchange.WebServices Question Pin
RCoate18-Mar-10 13:56
RCoate18-Mar-10 13:56 
AnswerRe: Microsoft.Exchange.WebServices Question Pin
RCoate21-Mar-10 17:09
RCoate21-Mar-10 17:09 
AnswerRe: Microsoft.Exchange.WebServices Question Pin
alisonstang229-Jul-11 4:38
alisonstang229-Jul-11 4:38 
Questionappend node by element name Pin
Jassim Rahma18-Mar-10 11:43
Jassim Rahma18-Mar-10 11:43 
AnswerRe: append node by element name Pin
Not Active18-Mar-10 12:10
mentorNot Active18-Mar-10 12:10 
AnswerRe: append node by element name Pin
carlecomm18-Mar-10 15:44
carlecomm18-Mar-10 15:44 
AnswerRe: append node by element name Pin
Mirko198018-Mar-10 22:27
Mirko198018-Mar-10 22:27 
QuestionHow do I call a method on the parent form from another form? Pin
Paul Stol18-Mar-10 10:09
Paul Stol18-Mar-10 10:09 
AnswerRe: How do I call a method on the parent form from another form? Pin
T M Gray18-Mar-10 10:46
T M Gray18-Mar-10 10:46 
AnswerRe: How do I call a method on the parent form from another form? Pin
DaveyM6918-Mar-10 11:15
professionalDaveyM6918-Mar-10 11:15 
QuestionQuestion with converting double to long Pin
Fenryl18-Mar-10 9:19
Fenryl18-Mar-10 9:19 
AnswerRe: Question with converting double to long Pin
Alaric_18-Mar-10 9:35
professionalAlaric_18-Mar-10 9:35 
GeneralRe: Question with converting double to long Pin
#realJSOP18-Mar-10 9:44
mve#realJSOP18-Mar-10 9:44 
AnswerRe: Question with converting double to long Pin
#realJSOP18-Mar-10 9:46
mve#realJSOP18-Mar-10 9:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.