volitelný parametr, C#/Parametr, Visual Studio 2022

This commit is contained in:
Lukáš Kaňka 2023-08-31 23:00:01 +02:00
parent be2640307c
commit ce64517296
8 changed files with 5 additions and 4 deletions

Binary file not shown.

View File

@ -10,15 +10,16 @@ namespace Parametr
{
public static void Main(string[] args)
{
PrintEmployeeDetail("Franta", 12, 2015);
PrintEmployeeDetail("Franta", 42, 2015);
PrintEmployeeDetail("Honza", 32, 2217, true);
PrintEmployeeDetail(age: 34, name: "Karel", empid: 2345); // tímto způsobem nemusíme dodržovat pořadí argumentů
//PrintEmployeeDetail(age: 34, name: "Karel", empid: 2345); // tímto způsobem nemusíme dodržovat pořadí argumentů
}
static void PrintEmployeeDetail(string name, int age, int empid)
static void PrintEmployeeDetail(string name, int age, int empid, bool supervisor = false) // <--- toto jsou parametry <--- , supervisor = nadřízený
{
Console.WriteLine($"Name : {name}, Age : {age}, Employee ID : {empid}");
Console.WriteLine($"Name : {name}, Age : {age}, Employee ID : {empid}, IsSupervizer : {supervisor}");
}
}