Overload finally

This commit is contained in:
Geir Okkenhaug Jerstad 2024-11-27 09:43:48 +01:00
parent 8a1b696755
commit 0aa442271f
11 changed files with 150 additions and 2 deletions

View file

@ -1,5 +1,4 @@
using System.Formats.Asn1;

namespace OverloadOgDefault
{
class Program
@ -21,6 +20,8 @@ namespace OverloadOgDefault
return a + b;
}
}
static void Main(string[] args)
{
OverloadExample calculator = new OverloadExample();
@ -28,6 +29,19 @@ namespace OverloadOgDefault
Console.WriteLine("Sum med to int-parametre: " + calculator.Add(calculator.Add(calculator.Add(2,2),2), 3));
Console.WriteLine("Sum med tre int-parametre: " + calculator.Add(2, 3, 9));
Console.WriteLine("Sum med to double-parametere: {0}", calculator.Add(2.3, 3.9));
int LeggSammen(int tall1 = 2, int tall2 = 3)
{
return tall1 + tall2;
}
void VisSum()
{
int sum = LeggSammen();
Console.WriteLine("Summen er: " + sum);
int sum2 = LeggSammen(2,2);
Console.WriteLine("Den andre summen er: " + sum2);
}
VisSum();
}
}
}