C#
Programming Language designed by Anders Hejlsberg.
Last updated
Programming Language designed by Anders Hejlsberg.
Last updated
The parentheses are known as the method invocation operator.
string - for words, phrases, or any alphanumeric data enclosed by double-quotes.
char - for a single alphanumeric character enclosed by single quotes.
int - for a numeric whole number.
decimal - for a number with decimal values and m/M as a literal suffix.
bool - for a true/false boolean values.
Note
string and char are only used for presentation, not for calculation.
Variables are temporary values you store in the computer's memory.
Before you can use a variable, you have to declare it.
To declare a variable, you first select a data type for the kind of data you want to store and then give the variable a name that follows the rules.
You must assign (set) a value to a variable before you can retrieve (get) a value from a variable.
You can initialize a variable by assigning a value to the variable at the point of declaration.
Assignment happens from right to left.
You use a single equals character as the assignment operator.
An implicitly typed local variable is created using the var
keyword. The var
keyword tells the compiler to infer the data type of the variable based on the value it is initialized to.
Note
You can only use the var
keyword if the variable is initialized.
An string/character escape sequence is a special instruction to the runtime that you want to insert a special character that will affect the output of your string.
\u
- add encoded characters in literal strings, then a four-character code representing some character in Unicode (UTF-16).
Console.WriteLine("\u3053\u3093\u306B\u3061\u306F World!");
Output: ใใใซใกใฏ World!
By default, all class members are sealed and cannot be overridden. To override we must expose it by using abstract
or virtual
keyword.