错误CS0246:找不到类型或命名空间名称“List”。你是否缺少使用指令的`System.Collections.Generic'? (CS0246)(CoolStuffBro) [英] Error CS0246: The type or namespace name `List' could not be found. Are you missing `System.Collections.Generic' using directive? (CS0246) (CoolStuffBro)

查看:101
本文介绍了错误CS0246:找不到类型或命名空间名称“List”。你是否缺少使用指令的`System.Collections.Generic'? (CS0246)(CoolStuffBro)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 使用系统; 

命名空间 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
悉尼
};
int 结果= Random.Next(names.Count);
names.RemoveAt(Result);
Console.WriteLine( ,名称);
string [] selectableNames = new string [ 3 ] {jade,boston,sydney};
Console.WriteLine( 欢迎来到找到你的约会应用程序。);
Console.WriteLine( 要开始在下面输入你的名字:);
name = Console.ReadLine();
Console.WriteLine( 欢迎{0},请在下面输入您的年龄:,名称);
age = int .Parse(Console.ReadLine());
Console.WriteLine( 查找{0}的日期,年龄{1}。 , 姓名年龄);

}
}
}

解决方案

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

Quote:

using System;

to

< pre lang =c#> 使用系统;
使用 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;


这篇关于错误CS0246:找不到类型或命名空间名称“List”。你是否缺少使用指令的`System.Collections.Generic'? (CS0246)(CoolStuffBro)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆