I have this code to Format an string
string s = "the first number is: {0} and the last is: {1} ";
int first = 2, last = 5;
string f = String.Format(s, first, last);
I want to extract first and last from final formatted string(f).It means I want to de-format the f to extract first and last(I have the format base(s)).
there is a way that is this:
- extract them using
string.Split()(hard and bad way)
but I think there is a simple solution in .Net but I don’t know what is this.
can anybody tell me what is the simple way?
Why not using some regex here ?
You can obviously make it more robust with proper error checking.