I have following method
public void DivideIntoSubStrings(string msg, string methodName, string userId)
{
string st = String.Format("{0}.{1}.{2}", msg, methodName, userId);
DoSomething(st);
}
when I call the following method in the method above and want to get msg, methodName and userId parameters as such
public void DoSomething(string bigString)
{
string st1 = bigString;
string[] st2 = st1.Split('.');
string t1 = st2[st2.Length - 1];
string t2 = st2[st2.Length - 2];
Console.WriteLine(t1);
Console.WriteLine(t2);
}
I'm always sure to get methodName and userId as they were passed into DivideIntoSubString(....) method but msg is a message parameter which can have anything typed into it or in other word I don't know the format of the msg string before hand as it will be passed on during the run-time. It can have commas, periods, underscores etc. So what would be a good idea to get the exact same value with same format of msg parameter as it was passed during the run-time.
DoSomethingif that is causing problems? Why not just keep all the strings separate?