Exceptions in C# (try, catch, finally)
Në shqip: Përjashtimet në C#
ShpjegimiSQ
Në C# i kap gabimet me try/catch, dhe finally ekzekutohet gjithmonë, me apo pa gabim. Kap gabime specifike (FormatException, IOException) para atyre të përgjithshme (Exception), dhe hedh të tuat me throw.
EnglishEN
In C# you catch errors with try/catch, and finally always runs, error or not. Catch specific errors (FormatException, IOException) before general ones (Exception), and throw your own with throw.
Si ta mendosh
Si portieri pas mbrojtjes, dhe finally është si fishkëllima në fund të ndeshjes — bie gjithmonë, sido që të ketë shkuar loja.
Lexoje në anglisht
Like the goalkeeper behind the defence, and finally is like the final whistle — it always blows, however the match went.
Shembull kodicsharp
try {
int n = int.Parse(Console.ReadLine()!);
} catch (FormatException) {
Console.WriteLine("Shkruaj një numër!");
} finally { Console.WriteLine("Mbaroi."); }