DEV Community

Fawole Ajibola Lukman
Fawole Ajibola Lukman

Posted on

Day 1 learning C#: variables and data types

Statements in C#

A statement is a complete instruction in C#.
The semicolon (;) tells the compiler that you’ve finished writing a command.

Example of a complete C# statement


Difference Between Console.WriteLine() and Console.Write() in C#

Console.WriteLine() prints a message to the console and moves the cursor to a new line afterward, similar to pressing Enter on the keyboard.

Console.Write() prints output on the same line without moving to a new line.

Screenshot demonstrating the difference between Console.Write() and Console.WriteLine() in C#


Common Mistakes New C# Programmers Make

Typing console instead of Console.
Using a comma instead of a period between Console and WriteLine.
Forgetting double quotation marks (" ").
Using single quotation marks (' ') for strings instead of double quotation marks.
Forgetting the semicolon (;) at the end of a statement.


Literals in C#

A literal is a constant value that does not change during program execution.

"Hello" // string literal
10 // integer literal
true // boolean literal


Common Data Types in C#

string --> stores words, phrases, or text.
char --> stores a single character.
int --> stores whole numbers.
decimal --> stores numbers with decimal points.
bool --> stores true or false values.


Today I learnt the basics of statements, literals, and data types in C#. I also understood the difference between Console.Write() and Console.WriteLine(). I used the Microsoft Learn documentation.

Top comments (0)