how can i read string values
QuoteNo:32586/CustomerNo:ABCDEF/TotalAmount:32/Processed:No
i want to read the values of the strings in any order
how can i read string values
QuoteNo:32586/CustomerNo:ABCDEF/TotalAmount:32/Processed:No
i want to read the values of the strings in any order
I'm all for neebie questions but i assume a certain level of google-ability
http://www.daniweb.com/forums/thread60361.html
http://www.dreamincode.net/forums/topic/12793-c%23-reading-each-character-of-a-string/
http://articles.techrepublic.com.com/5100-10878_11-6030362.html
Not sure what you're looking to do, but from your given string it may be the following
string input = "QuoteNo:32586/CustomerNo:ABCDEF/TotalAmount:32/Processed:No";
var query = from pair in input.Split('/')
let items = pair.Split(':')
select new
{
Part = items[0],
Value = items[1]
};
// turn into list and access by index
var list = query.ToList();
// or turn into dictionary and access by key
Dictionary<string, string> dictionary
= query.ToDictionary(item => item.Part, item => item.Value);
string str = "QuoteNo:32586/CustomerNo:ABCDEF/TotalAmount:32/Processed:No";
string split = str.Split('/');
foreach(string s in split)
{
int index = s.IndexOf(':');
if (index <= 0 || index + 1 >= str.Length) throw new Exception();
string name = s.SubString(0,index);
string value = s.SubString(index+1);
}