且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误CS0246:找不到类型或命名空间名称“List”。你是否缺少使用指令的`System.Collections.Generic'? (CS0246)(CoolStuffBro)

更新时间:2023-11-17 13:58:10

错误信息非常清楚,只需更改

Quote:

using System;

to

使用系统;
使用 System.Collections.Generic;


using System;

namespace CoolStuffBro
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string name;
			int age;
			string jade;
			string boston;
			string sydney;
			var names = new List<string> {
				"jade",
				"boston",
				"sydney"
			};
			int Result = Random.Next (names.Count);
			names.RemoveAt (Result);
			Console.WriteLine ("",names);
			string[] selectableNames = new string[3] { jade, boston, sydney };
			Console.WriteLine ("Welcome to the find your date app.");
			Console.WriteLine ("To begin type your name below: ");
			name = Console.ReadLine ();
			Console.WriteLine ("Welcome {0}, please enter your age below:",name);
			age = int.Parse (Console.ReadLine ());
			Console.WriteLine ("Finding dates for {0}, age {1}.", name, age);

		}
	}
}

The error message is pretty clear, just change from
Quote:

using System;

to

using System;
using System.Collections.Generic;