Here is the text file
country1: 93#country2: 355#country3: 213#country4: 376#country5: 244#country6: 54#country7: 374#
For this ASP.NET web services,when i declare string temp ouside "for" loops, Error "Use of unassigned local variable 'temp'"
[webMethod]
public string[] getContryCode ()
{
string temp;
string[] data = File.ReadAllLines(@"countryCode.txt");
string[] country = data[0].Split('#');
for (int i = 0; i < country.Length; i++ )
{
temp = country[i];
}
//const string f = "countryCode.txt";
return temp.Split(':');
}
If i declare string temp inside a loop,i can't return a value of "temp.Split(':')". Need find a way to solve it
originl file format: #country1:code1#country2:code2#
array list 'country': [0] country1 code1 country2 code2
- i can get this work b split
temp.split(':') : should get things like this [0]country1 [1] code1 [2] country2 [3] code2