using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
string[] arr = {"a","b","c","d"};
foreach(string str in arr)
{
Console.Write(str);
}
Console.WriteLine("--------");
string[] arr2 = {"d","e","f","g", "h", "i"};
arr = arr2;
foreach(string str in arr)
{
Console.Write(str);
}
}
}
결과 : abcd--------
defghi
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
Dictionary<int, string> dict1 = new Dictionary<int, string>()
{
{1, "one"},
{2, "two"},
{3, "three"}
};
foreach(KeyValuePair<int, string> pair in dict1)
{
Console.Write(pair.Key);
Console.Write(pair.Value);
}
Console.WriteLine("--------");
Dictionary<int, string> dict2 = new Dictionary<int, string>()
{
{3, "threethree"},
{4, "four"},
{5, "five"},
{6, "six"}
};
dict1 = dict2;
foreach(KeyValuePair<int, string> pair in dict1)
{
Console.Write(pair.Key);
Console.Write(pair.Value);
}
}
}
결과 : 1one2two3three--------
3threethree4four5five6six
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
List<string> list = new List<string>(){"a","b","c","d"};//
foreach(string str in list)
{
Console.Write(str);
}
Console.WriteLine("--------");
List<string> list2 = new List<string>(){"d","e","f","g", "h"};
list = list2;
foreach(string str in list)
{
Console.Write(str);
}
}
}
결과 : abcd--------
defgh
'유니티(Unity)' 카테고리의 다른 글
Collection was modified; enumeration operation may not execute. 에러. 리스트 요소 제거 시 주의 할점 (0) | 2024.02.17 |
---|---|
다중 스레드에서 딕셔너리 동시 접근시 에러 (0) | 2024.01.26 |
Unity D3D11 에러 해결방법 (0) | 2023.12.11 |
Unity glTF Importer (1) | 2023.11.01 |
Firebase Auth 구글 소셜 로그인 구현 시 주의할 점 (0) | 2023.09.02 |