overloading
This commit is contained in:
parent
f186fcf653
commit
558073a24d
3 changed files with 59 additions and 0 deletions
|
@ -0,0 +1,10 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
33
Emne 3/OverloadOgDefault/OverloadOgDefault/Program.cs
Normal file
33
Emne 3/OverloadOgDefault/OverloadOgDefault/Program.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Formats.Asn1;
|
||||
|
||||
namespace OverloadOgDefault
|
||||
{
|
||||
class Program
|
||||
{
|
||||
class OverloadExample
|
||||
{
|
||||
public int Add(int a, int b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
public int Add(int a, int b, int c)
|
||||
{
|
||||
return a + b + c;
|
||||
}
|
||||
|
||||
public double Add(double a, double b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
}
|
||||
static void Main(string[] args)
|
||||
{
|
||||
OverloadExample calculator = new OverloadExample();
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue