Strings are an imuutable type. You dont directly change their value, you assign a new value to them. As such, their functions do not change their value. For example:
class Program
{
static void Main(string[] args)
{
string test = "This is a test";
Console.WriteLine("Initial value: {0}", test);
test.Replace(" ", "_");
Console.WriteLine("Value after method: {0}", test);
test = test.Replace(" ", "_");
Console.WriteLine("Value after method and assignment: {0}", test);
Console.ReadKey();
}
}
So when you call str2.Split it doesnt make any changes to str1. Split is a method which returns an array of strings. You need to store the array that each split method returns and compare the elements of the arrays.
Try rewriting it and let us know where you get to.
Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246