C#/수업내용
03/15 배열 선언, 인스턴스 생성, 할당, 출력 연습 3
박준희
2021. 3. 15. 11:11
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study03
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Main");
new App();
}
}
}
App.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Study03
{
public class App
{
public App()
{
string[] itemNames = new string[] { "장검", "단검", "활", "도끼" };
int idx = 0;
foreach(string str in itemNames)
{
if(str.Equals("단검"))
{
Console.WriteLine("{0}을 찾았습니다, index: {1}", str, idx);
}
idx++;
}
}
}
}