Kivételek kezelése
This commit is contained in:
1 parent
eb560ac912
commit
c5a502262d
4 files changed
+90
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
<Solution>
|
||||||
|
<Project Path="Kivetelek/Kivetelek.csproj" />
|
||||||
|
</Solution>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
namespace Kivetelek
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.Write("Adjon meg egy számot!");
|
||||||
|
int szam = Convert.ToInt32(Console.ReadLine());
|
||||||
|
Sportolo sportolo = new Sportolo { Nev="Elek",Magassag=78};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Hibás argumentum!");
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hibás argumentum!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (FormatException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Számot kell megadni!");
|
||||||
|
}
|
||||||
|
catch (OverflowException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("A megadott érték túl nagy!");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.StackTrace);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Console.WriteLine("Ami itt van az mindig lefut.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Megyünk tovább...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Kivetelek
|
||||||
|
{
|
||||||
|
public class Sportolo
|
||||||
|
{
|
||||||
|
public string Nev { get; set; }
|
||||||
|
|
||||||
|
private int magassag;
|
||||||
|
public int Magassag {
|
||||||
|
|
||||||
|
get { return magassag; }
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value>100)
|
||||||
|
{
|
||||||
|
magassag = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Hibás magasság érték!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user