This is the simple example of label statement program which can be easily understand by any one.
In the program we need to create a "label :" in the starting of the program after declaring variable.
We create label because to give command to a program in runtime mode with "goto label;" which will take the execution at label and start it again from label.
In my program it will ask you again and again to "Enter your name" and print your name with other statement.
NOTE :- You can also put the if else statement which will ask you to continue or exit the
execution. Try it.
ENJOY CODING !!!!
___________________________________________________________________________________
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Label_statement { class PostSlush { static void Main(string[] args) { string name; label: //Now,creating label with colon(:) Console.WriteLine("Enter your name:"); name = Console.ReadLine(); Console.WriteLine("Welcome {0}", name); goto label; //it will jump to label statement } } }
Output :
Tags:
csharp.net