Tutorial de Python 3 para principiantes.
Declaring Variables
int age = 25;
double price = 9.99;
bool isActive = true;
char grade = 'A';
string name = "Alice";
Built-In Types
| C# Type | .NET Type | Size | Example |
| int | Int32 | 4 bytes | 42 |
| long | Int64 | 8 bytes | 9999999999L |
| float | Single | 4 bytes | 3.14f |
| double | Double | 8 bytes | 3.14159 |
| decimal | Decimal | 16 bytes | 9.99m (money) |
| bool | Boolean | 1 byte | true / false |
| char | Char | 2 bytes | 'X' |
| string | String | dynamic | "hello" |
var — Type Inference
var count = 10; // int
var price = 9.99; // double
var name = "Alice"; // string
// Useful in loops:
var numbers = new List<int> { 1, 2, 3 };
foreach (var n in numbers) Console.WriteLine(n);
Constants and readonly
const double PI = 3.14159265; // compile-time constant
readonly int maxSize; // set once in constructor
// PI = 3.0; // ❌ error
Nullable Types
int? nullableInt = null;
string? nullableStr = null;
// Null-coalescing operator
int value = nullableInt ?? 0; // 0 if null
// Null-conditional operator
int? len = nullableStr?.Length; // null if str is null
String Interpolation
string firstName = "Alice";
int age = 30;
string msg = $"My name is {firstName} and I am {age} years old.";
Console.WriteLine(msg);