나는 C# 초보자 질문이 있습니다. 이 두 가지 중에서도 훌륭한 연습은 무엇이라고 생각합니까? ... 배열보다 목록이 더 빠르거나 빠릅니까?목록 배열 사용 - 모범 사례
//Method 1
int[] i_array = { 2, 0, 110, 53455, 2223 };
if (someBolean)
{
Array.Resize(ref i_array, i_array.Length + 1);
i_array[i_array.Length - 1] = someIntValue;
}
//Method 2
var i_list = new List<int>();
i_list.AddRange(new int[] { 2, 0, 110, 53455, 2223 });
if (someBolean)
i_list.Add(someIntValue);
배열의 크기를 일정하게 변경하면 방법 2의 목록을 사용할 수도 있습니다. –
어렵다는 것을 알고 있지만 학습 곡선의이 단계는 성능이 문제가 될 때까지 성능에 대해 걱정하지 마십시오 *. http://stackoverflow.com/questions/211414/is-premature-optimization-really-the-root-of-all-evil –