views:

230

answers:

2

I have a semicolon-separated list of values, for example:

strins s = "param1=true;param2=4;param3=2.0f;param4=sometext;";

I need a functions:

public bool ExtractBool(string parameterName, string @params);
public int ExtractInt(string parameterName, string @params);
public float ExtractFloat(string parameterName, string @params);
public string ExtractString(string parameterName, string @params);

Is there a special functions in .net that can help me with semicolon-separated list ?

PS: parameter names are equal within a list.

+2  A: 

As a starting point, what you need is the String.Split() method - it will split your string into a string array.

You'll find loads of examples of this all over the web.

stupid-phil
A: 

For string better you can use Split(',');

You can try this for split comma

string s ="param1=true;param2=4;param3=2.0f;param4=sometext;";

string[] sArray = s.Split(',')
anishmarokey
I think that you mean: string[] sArray = s.Split(';');
Ardman
thanks you are right.. Ardman
anishmarokey