初級 › type or namespace name could not be found の原因と直し方 › パターン3
type or namespace name could not be found の原因と直し方
List<T>やDictionary、StringBuilderなど、名前空間ごとに分かれたクラスを使うにはusingディレクティブが必要です。
1 _________________________________ ^ 2 class Program { 3 static void Main(string[] args) { 4 Dictionary<string, int> scores = new Dictionary<string, int>(); 5 scores["a"] = 1; 6 System.Console.WriteLine(scores.Count); 7 } 8 }
Program.cs(4,9): error CS0246: The type or namespace name 'Dictionary<,>' could not be found (are you missing a using directive or an assembly reference?)
空欄を埋めてビルドを通す
DictionaryもList同様System.Collections.Genericにあります。コレクション系はまとめてここにまとまっています。
次の問題