When i Execute this code i got some interesting results.
string readText = File.ReadAllText("d:\\temp.txt");
Console.WriteLine(readText);
Console.WriteLine("From File: "+Regex.Matches(readText,"$").Count);//-->2
Console.WriteLine("Add \\n to the File: "+Regex.Matches(readText + "\n", "$").Count);//--->2
Console.WriteLine("Add multiple \\n to the file: "+Regex.Matches(readText + "\n\n\n", "$").Count);//--->2
Console.WriteLine("on Text \"sample\": "+Regex.Matches("sample", "$").Count);//--->1
Console.WriteLine("on Text \"sample\\n\\n\\n\": "+Regex.Matches("sample" + "\n\n\n", "$").Count);//--->2
Output:
First line
third
Line 6
Line 7
From File: 2
Add \n to the File: 2
Add multiple \n to the file: 2
on Text "sample": 1
on Text "sample\n\n\n": 2
why its gives me results like this. can any one ex-plane this?