Questions et réponses d'entretien les plus demandées et tests en ligne
Plateforme d'apprentissage pour la preparation aux entretiens, les tests en ligne, les tutoriels et la pratique en direct

Developpez vos competences grace a des parcours cibles, des tests blancs et un contenu pret pour l'entretien.

WithoutBook rassemble des questions d'entretien par sujet, des tests pratiques en ligne, des tutoriels et des guides de comparaison dans un espace d'apprentissage reactif.

Chapter 2

Syntax, Variables, Data Types, Operators, and Input Output

Learn the basic building blocks of C# including variables, types, expressions, interpolation, and console interaction.

Inside this chapter

  1. Variables and Data Types
  2. Type Categories
  3. Console Input and Output
  4. Operators and Expressions
  5. Type Inference with var
  6. Real-World Usage Snapshot

Series navigation

Study the chapters in order for the clearest path from C# syntax and OOP to modern .NET web development, data access, async programming, architecture, and advanced engineering practice. Use the navigation at the bottom to move smoothly through the full series.

Tutorial Home

Chapter 2

Variables and Data Types

int age = 25;
double salary = 52000.75;
char grade = 'A';
bool isActive = true;
string name = "Alice";

C# is strongly typed and expressive. It gives developers a rich set of built-in types and clear syntax for declaring and initializing values.

Chapter 2

Type Categories

Category Examples
Integral typesint, long, short, byte
Floating-point typesfloat, double, decimal
Character and textchar, string
Logical typebool

decimal is especially useful in money-related applications because it avoids some binary floating-point accuracy issues.

Chapter 2

Console Input and Output

Console.Write("Enter your name: ");
string? userName = Console.ReadLine();
Console.WriteLine($"Hello, {userName}");

String interpolation with $"" is one of the most readable features in C#. Students should learn it early because it improves clarity.

Chapter 2

Operators and Expressions

int a = 10;
int b = 3;
int sum = a + b;
bool result = a > b && b > 0;
int remainder = a % b;

C# supports arithmetic, relational, logical, assignment, null-coalescing, conditional, and many other operators. Students should understand precedence and keep expressions readable.

Chapter 2

Type Inference with var

var city = "Berlin";
var count = 5;

var does not make C# dynamically typed. The compiler still determines the type statically. Good style means using var when it improves readability, not when it hides meaning.

Chapter 2

Real-World Usage Snapshot

These basics appear everywhere from console apps to enterprise APIs. Correct type choices, readable expressions, and good output formatting help prevent confusion later in business logic and data processing code.

Copyright © 2026, WithoutBook.