using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
/*
//제네릭 목록에서 요소를 제거합니다.
var numbers = new List<int> {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
//Remove old numbers.
for(var index=numbers.Count -1; index >=0; index--){
if (numbers[index] % 2 == 1){
//Remove the element by specifying the zero-based index in the list
numbers.RemoveAt(index);
}
numbers.ForEach(
number => Console.Write(number+" "));
*/
//제거할 개체를 지정하여 컬렉션에서 요소를 제거합니다.
var salmons = new List<string> {"chinook", "coho", "pink", "sockeye"};
//Remove an element from the list by specifying the object.
salmons.Remove("coho");
//Iterate through the list
foreach(var salmon in salmons){
Console.Write(salmon + " ");
//foreach 대신 for를 사용하여 컬렉션의 요소를 반복합니다.
var salmons = new List<string> {"ListTest", "coho", "pink", "sockeye"};
for(var index = 0 ; index<salmons.Count; index++){
Console.Write(salmons[index] + " " );
//문자열 목록을 만든 다음, foreach 문을 사용하여 문자열을 반복합니다.
//Create a list of strings
var salmons = new List<string>();
salmons.Add("Chinook");
salmons.Add("coho");
salmons.Add("pink");
salmons.Add("sockeye");
Console.Write(salmon+ " ");