У меня есть простой код в C#не может инициализировать типа 'Int' ошибка
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyProject
{
public static class Class1
{
public static int[] Iparray = new int { 12, 9, 4, 99, 120, 1, 3, 10 };
}
}
однако на (Ctrl + Сдвиг + B) ошибка отображаемая
Cannot initialize type 'int' with a collection initializer because it does not implement 'System.Collections.IEnumerable'
Я использую vs 2010 и и .NET framework 4
Благодарю вас Всего
Без '[]' компилятор пытается выполнить 'int tmp = new int(); tmp.Add (12); tmp.Add (9); ...; Iparray = tmp; '. Это _collection initializer_. –