Ok im a complete newbie at C#, bascially I put this together with as I thought careful planning.
I am wanting to search a text file line by line for "xxx" To me this looks to be very straight forward but the compiler does not like it =/
Its giving me 2 Errors:
D:\MyDocs\Visual Studio Projects\ConsoleApplication2\Class1.cs(25): Control cannot fall through from one case label (case 1 to another
D:\MyDocs\Visual Studio Projects\ConsoleApplication2\Class1.cs(25): Control cannot fall through from one case label (default to another
I am guessing, that it does not like the dynamic generation of the "to search" string, or its not public or something, like i said im a total newbie =/
If anyone could give me some pointers as to my solution that would be great, not looking for someone to write my code.
Below is my code
Thanks
Rich
I am wanting to search a text file line by line for "xxx" To me this looks to be very straight forward but the compiler does not like it =/
Its giving me 2 Errors:
D:\MyDocs\Visual Studio Projects\ConsoleApplication2\Class1.cs(25): Control cannot fall through from one case label (case 1 to another
D:\MyDocs\Visual Studio Projects\ConsoleApplication2\Class1.cs(25): Control cannot fall through from one case label (default to another
I am guessing, that it does not like the dynamic generation of the "to search" string, or its not public or something, like i said im a total newbie =/
If anyone could give me some pointers as to my solution that would be great, not looking for someone to write my code.
Below is my code
C#:
using System;
namespace ConsoleApplication2
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
int counter = 0;
string line;
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader("c:\\test.txt");
while((line = file.ReadLine()) != null)
{
string searchThis = "Bill";
switch(line.IndexOf(searchThis))
{
case 1:
Console.WriteLine (line);
default:
Console.WriteLine ("Nothing found");
}
counter++;
}
file.Close();
// Suspend the screen.
Console.ReadLine();
}
}
}
Rich