0% found this document useful (0 votes)
7 views3 pages

Variables

The document explains basic C# programming concepts, including the use of semicolons to end statements and the importance of data types such as int, double, string, char, and bool. It contrasts C#'s strong typing with Python's dynamic typing and introduces the 'var' keyword for type inference. Additionally, it provides a simple practice exercise to reinforce these concepts and hints at further learning about user input.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Variables

The document explains basic C# programming concepts, including the use of semicolons to end statements and the importance of data types such as int, double, string, char, and bool. It contrasts C#'s strong typing with Python's dynamic typing and introduces the 'var' keyword for type inference. Additionally, it provides a simple practice exercise to reinforce these concepts and hints at further learning about user input.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Yeah bruv, you’re basically getting it 👍

1️⃣ ; is like a full stop


In C#, the semicolon ; ends a statement.
Think of it like a full stop in English.
Example:
int age = 16;
[Link](age);
Meaning:
statement 1 ;
statement 2 ;
If you forget it:
int age = 16
[Link](age);
C# will give an error.
So yeah, mentally remember:
; = end of instruction

2️⃣ Do you have to memorize data types?


At first yes a little, but there are only a few you’ll use most of the time.
These are the main ones beginners use:

Data What it Examp


type stores le
int whole 5, 10
numbers
double decimal 5.6
numbers
string text "Hello"
char single 'A'
character
bool true/false true
Example program:
int age = 16;
double marks = 92.5;
string name = "Supreet";
char grade = 'A';
bool passed = true;
[Link](name);
[Link](age);
[Link](marks);

3️⃣ Quick comparison with Python


In Python:
age = 16
name = "Supreet"
Python figures out the type automatically.
But in C# you specify it:
int age = 16;
string name = "Supreet";
That’s called a strongly typed language.

4️⃣ Small trick beginners like


C# can also sometimes figure out the type automatically using var.
Example:
var age = 16;
var name = "Supreet";
C# understands:
age → int
name → string
But beginners usually learn the actual types first.

5️⃣ Tiny practice (do this once)


Put this in [Link]:
string name = "Supreet";
int age = 16;

[Link]("Name: " + name);


[Link]("Age: " + age);
Run with:
dotnet run

You’re basically at the real starting point of programming now.


Next logical step is user input, which introduces:
[Link]()
That’s the C# version of Python’s input().
If you want, I can show you a 3-line program that already behaves like a
real app (it asks the user something and responds).

You might also like