C# Note
Note for C# programming language
C# Note
1 Hello World
1.1 Demo
1 | using System; |
1.2 Notes
- main function is written as
static void Main(string[] args)
Main
starts with Capitalized character
- To print text in console screen, use:
- Auto end with new line:
Console.WriteLine(...)
- no auto ending new line:
Console.Write(...)
- Auto end with new line:
- Comment has 3 types:
- document comment:
/// ...
- Attention: this should be only written in front of class/method/attribute.
- block comment:
/* ... */
- line comment:
// ...
- document comment:
- type cast:
- lower precision variable can be converted to higher precision automatically, however, higher precision variable has to be cast to lower precision manually by code.
c# double d = 2.5; int x = (int)d + 1; // cause ERROR if no (int) cast