using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace Study09
{
class App
{
//생성자
public App()
{
Console.WriteLine("App");
int[] arr0 = { 1, 2, 3 };
int[] arr1 = new int[3];
string[] arr2 = { "t", "r", "e" };
string[] arr3 = new string[3];
CopyArray(arr0, arr1);
CopyArray(arr2, arr3);
Hero[] arr4 = { new Hero(), new Hero(), new Hero() };
Hero[] arr5 = new Hero[3];
for (int i = 0; i < arr1.Length; i++)
{
Console.WriteLine(arr1[i]);
}
CopyArray<int>(arr0, arr1);
CopyArray<string>(arr2, arr3);
CopyArray<Hero>(arr4, arr5);
}
void CopyArray<T>(T[] a, T[] b)
{
for(int i = 0; i < a.Length; i++)
{
b[i] = a[i];
}
}
void CopyArray(int[] a, int[] b)
{
for (int i = 0; i < a.Length; i++)
{
b[i] = a[i];
}
}
//메서드 오버로딩
void CopyArray(string[] a, string[] b)
{
for (int i = 0; i < a.Length; i++)
{
b[i] = a[i];
}
}
void CopyArray(Hero[] a, Hero[] b)
{
for (int i = 0; i < a.Length; i++)
{
b[i] = a[i];
}
}
}
}
'C# > 수업내용' 카테고리의 다른 글
[ C# 8일차 ] Collection 연습_List, Queue, Stack (0) | 2023.01.10 |
---|---|
[ C# 8일차 ] Generic 일반화 Class (0) | 2023.01.10 |
[ C# 8일차 ] Struct 구조체 (0) | 2023.01.10 |
[ C# 8일차 ] Collections_Hashtable (0) | 2023.01.10 |
[ C# 8일차 ] Collections_Queue, Stack (0) | 2023.01.10 |