BasicKnowledgeCSharp/LessonsAndTasks/Lesson 36 - Перегрузка методов/Program.cs
Dvurechensky 058c8f2679 1.0
Main
2024-10-05 09:59:53 +03:00

36 lines
868 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
/*
* Перегрузка методов (несколько реализаций одного и того же метода с разной сигнатурой)
*/
class Program
{
public static int Sum(int a, int b)
{
return a + b;
}
public static int Sum(int a, int b, int c)
{
return a + b + c;
}
/// <summary>
/// Сумма чисел разных типов
/// </summary>
/// <param name="a">Число 1</param>
/// <param name="b">Число 2(double)</param>
/// <param name="c">Число 3</param>
/// <returns>Сумма</returns>
public static double Sum(int a, double b, int c)
{
return (double)a + b + c;
}
static void Main()
{
double sum = Sum(1, 2.3, 4);
Console.WriteLine(sum);
Console.ReadKey();
}
}