-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC# 101 - HW4.cs
68 lines (55 loc) · 1.97 KB
/
C# 101 - HW4.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
namespace hatayonetimi
{
class Program
{
static void Main(string[] args)
{
//string hatası
try{
Console.WriteLine("Bir sayı giriniz:");
int sayi =Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Girmiş olduğunuz sayı:" + sayi);
}
catch(Exception eas)
{
Console.WriteLine(" Hata:" + eas.Message.ToString());
}
finally
{
Console.WriteLine("İşlem tamamlandı.");
}
//null=> int hatası
//Parse : string ifadeleri int'e çevirir
try
{
//int a=int.Parse(null); //ArgumentNullException geçersiz girdi
//int a=int.Parse("test"); //FormatException biçim geçersiz
int a=int.Parse("-20000000000"); //OverflowException taşma ya da aralık dışında bir deger girildiğinde
}
catch (ArgumentNullException se)
{
Console.WriteLine("Boş değer girdiniz!");
Console.WriteLine(se);
Console.WriteLine(se.Message);
}
catch(FormatException fe)
{
Console.WriteLine("veri tipi uygun değil");
Console.WriteLine(fe);
}
catch(OverflowException of)
{
Console.WriteLine("Çok küçük ya da çok büyük bir değer girdiniz.");
Console.WriteLine(of);
}
finally{
Console.WriteLine("işlem başarıyla tammalandı!")
}
//sayıyı denetleyen bir sistem yok string çevrim var
/*Console.WriteLine("Bir sayı giriniz:");
int sayi=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Girmiş olduğunuz sayı:" + sayi);*/
}
}
}