C#/C# Concept

[C#] 오버로딩

군우 2018. 4. 5. 09:35
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApplication12
{
    class Program
    {
        static void Main(string[] args)
        {
            Program oc = new Program();
 
            int i = oc.Plus(35);
            float j = oc.Plus(0.1f, 0.2f);
            double k = oc.Plus(0.50.7);
 
            Console.WriteLine("int 합: {0}", i);
            Console.WriteLine("float 합: {0}", j);
            Console.WriteLine("double 합: {0}", k);
        }
        public int Plus(int a, int b)
        {
            return a + b;
        }
        public float Plus(float a, float b)
        {
            return a + b;
        }
        public double Plus(double a, double b)
        {
            return a + b;
        }
 
    }
}
cs