Introduction
Strong typing helps catch mistakes early by making sure you use the right kind of data in your program.
Strong typing helps catch mistakes early by making sure you use the right kind of data in your program.
int number = 5; string name = "Alice"; bool isActive = true;
int for numbers or string for text.age holds a number, city holds text, and isStudent holds true or false.int age = 30; string city = "New York"; bool isStudent = false;
double holds decimal numbers, and char holds a single character.double price = 19.99; char grade = 'A';
This program shows how variables have fixed types. Trying to put text into a number variable causes an error before running.
using System; class Program { static void Main() { int number = 10; string text = "Hello"; // Uncommenting the next line will cause a compile error // number = "Ten"; // Error: cannot assign string to int Console.WriteLine($"Number: {number}"); Console.WriteLine($"Text: {text}"); } }
Strong typing helps prevent mistakes by checking types when you write code.
It makes your code safer and easier to fix if something goes wrong.
Strong typing means each variable has a fixed type.
This helps catch errors early and keeps code clear.
C# uses strong typing to make programming safer and easier.
int x = 5;
string y = "5";
Console.WriteLine(x == y);
double price = 19.99;
int quantity = "5";
double total = price * quantity;
Console.WriteLine(total);
Pass the test and this pattern moves unknown