Free Source Code and Tutorials

Custom Search


CSharplogo1 syntax

C#  is a bit the same with Java depending on the syntax that derives from C and C++. C#  program is in need of powerful structure when it comes to its object-oriented nature in terms of classes. Wherein, the statement needs to be exact.


A statement is a basic implementation of C# program. This statement can be declared as variable, execute an event by calling a method, create a method and many more, and it ends with semicolon.



namespace myFirstCsharp
 public partial class Form1 : Form
 public Form1()
 //This method is for the designer support.
 //Reminder: do not modify the content of this method with the code editor.

 //creating a method
 private void HelloWorld()
 string msg;// declaring varible
 msg = "Hello world!"; //storing value in a variable
 MessageBox.Show(msg); //desplaying value of a variable
 private void button1_Click(object sender, EventArgs e)
 HelloWorld(); // calling a method




A statement between { } braces is the body of the method. These braces serve as the fence of the codes in the method.  This will help you identify what is the process or event you’re going to execute.


 private void Calculate()
 { //start of the method

 //variables are accessable any where inside the method.
 int input1 = 3;
 int input2 = 2;

 if (input1 > 2)
 //variable is accessable here only.
 int tot;
 tot = input1 - input2;

 }//end of the method

 private void button1_Click(object sender, EventArgs e)
 Calculate(); // calling a method



Facebook Comments
(Visited 6 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!

%d bloggers like this: