- Back to Home »
- C#.NET »
- Rules in C#.NET
Posted by :
Sudhir Chekuri
Wednesday, 30 December 2015
1. It is a case sensitive language
i.e., Lowercase letter is not same as Uppercase letter.int i; and int I;
They are different variables.
2. Every block of code should start with opening curly brace and end with closing curly brace.
opening brace {
} closing brace
3. Every statement should end with semi colon(;).
Example: Console.Write("hello world");
4. Every string value should be surrounded by double quotes.
Example: string s="hai";
5. Every character value should be surrounded by single quotes.
Example: char c='a';
6. No need of any quotes around numeric values.
Example: int i=515; float f=533.558f;
7. // is for comments in C#.
Comments are lines in source code that are negotiated by compiler.
8. All the keywords in C# will be in lowercase.
Example: int, using, class, ...
9. All First characters of every word in the predefined namespace, class and method names will be in uppercase and rest all characters will be in lowercase.
Example: System, Console, Read, ReadLine
10. Every line of code in C# should be written in class. Classes should be written in namespaces. Methods should be written inside class.
Namespace
{
Class
{
Method
{
Code
}
}
}
i.e., Lowercase letter is not same as Uppercase letter.int i; and int I;
They are different variables.
2. Every block of code should start with opening curly brace and end with closing curly brace.
opening brace {
} closing brace
3. Every statement should end with semi colon(;).
Example: Console.Write("hello world");
4. Every string value should be surrounded by double quotes.
Example: string s="hai";
5. Every character value should be surrounded by single quotes.
Example: char c='a';
6. No need of any quotes around numeric values.
Example: int i=515; float f=533.558f;
7. // is for comments in C#.
Comments are lines in source code that are negotiated by compiler.
8. All the keywords in C# will be in lowercase.
Example: int, using, class, ...
9. All First characters of every word in the predefined namespace, class and method names will be in uppercase and rest all characters will be in lowercase.
Example: System, Console, Read, ReadLine
10. Every line of code in C# should be written in class. Classes should be written in namespaces. Methods should be written inside class.
Namespace
{
Class
{
Method
{
Code
}
}
}