Embedded statement cannot be a declaration or labeled statement error

“Embedded statement cannot be a declaration or labeled statement” error can drive you crazy sometimes like it did to me .i have a 3-4 lines code(in c#) and it took me enough time to resolve this error .

My code before :

if (args.Length > 0)
HCopen o = new HCopen(args[0]);
else
Console.WriteLine(“No Args”);

After Correction :

if (args.Length > 0) { HCopen o = new HCopen(args[0]); }

else { Console.WriteLine(“Usage: HCopen “); }

Now crux of the story is that code generate Compiler Error CS1023

Advertisements

One thought on “Embedded statement cannot be a declaration or labeled statement error

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s