overloading
This commit is contained in:
parent
f186fcf653
commit
558073a24d
16
Emne 3/OverloadOgDefault/OverloadOgDefault.sln
Normal file
16
Emne 3/OverloadOgDefault/OverloadOgDefault.sln
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OverloadOgDefault", "OverloadOgDefault\OverloadOgDefault.csproj", "{1B403057-2541-4916-ACEC-75CEB5AA053C}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{1B403057-2541-4916-ACEC-75CEB5AA053C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1B403057-2541-4916-ACEC-75CEB5AA053C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1B403057-2541-4916-ACEC-75CEB5AA053C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1B403057-2541-4916-ACEC-75CEB5AA053C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -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…
Reference in a new issue