I have a textfile which contains texts.Now i have a string say 945789
.Now i want to get the line on which this string is present from the textfile but i am not able to search and get the line..
Here is the code.
foreach (var line in File.ReadAllLines(pathToFile))
{
//How to get the line with the string
}
Please help me..
Update..
for (int i = 9; i >=3; i--) {
spsubcallingno = subcallingno.Substring(0, i);
int lineNumber = 0;
foreach (var spline in File.ReadAllLines(sp))
{
lineNumber++;
if (line.Contains(spsubcallingno))
{
return lineNumber;
}
}
}
I am getting a red line mark in return