采用.net2003 C#编译环境
程序如下:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace GetStudent
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
string connStr="server=(local);Initial Catalog=students;user Id=sa;password=sa;";
    SqlConnection conn=new SqlConnection(connStr);
    conn.Open();
SqlCommand cmd=conn.CreateCommand();
cmd.CommandText="Select ID,sName from student";
SqlDataReader reader=cmd.ExecuteReader();
string output;
while (reader.Read())
{
output=string.Format("学生 {0}\t的学号是 {1}",
reader.GetString(1),reader.GetSting(0));
Console.WriteLine(output);
}
reader.Close();
conn.Close();
}
}
}报错如下
error CS0234: 类型或命名空间名称“Generic”在类或命名空间“System.Collections”中不存在(是否缺少程序集引用?)我上网查了下,有人答案如下:System.Collections.Generic 命名空间在 .NET Framework 2.0 版中是新增的 
你用的是.NET Framework 1.X版本吧? 
下载一个.NET Framework 2.0安装一下或者改用visual stdio .net 2005以上的版本我重新装了.NET Framework 2.0,问题还在。求助各位前辈。

解决方案 »

  1.   

    用Visual Studio .NET 2003不能使用.NET Framework 2.0的类库
    你要想用Generic必须用Framework 2.0 SDK命令行编译,或用Visual Studio 2005
      

  2.   

    你用.NET Framework 2.0的命令行编译肯定可以..
    VS2003用的就是.NET Framework 1.X版本,不会因为你装了.NET Framework 2.0马上就支持C# 2.0的语法
      

  3.   

    谢谢fancyf(凡瑞)和amandag(高歌),但是如何采用.NET Framework 2.0的命令行编译,小弟新人,多多指点啊。
      

  4.   

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe form1.cs form2.cs
      

  5.   

    使用楼上的csc编译,不过你最好把它加到环境变量里面,否则编译你的cs文件需要全路径还有,可能需要使用 /r 开关引用某些.dll
      

  6.   

    用VS2005带的命令行工具,进入你的目标文件下
    csc  *.cs
      

  7.   

    说实话,没在这种环境中测试过,你搜索一下你机器上csc.exe分别在那个目录下,有没有貌似在2.0的目录下的,编译肯定要这个东东而且你装的.NET Framework 2.0是运行时环境(大概26M)还是SDK(100M以上),仅有运行时环境是不够的
      

  8.   

    我找到一个csc.exe 的文件,但是双击后就出现一个命令框,闪现一下就没有了
      

  9.   

    是运行环境,就是大概22.9M的样子,那我是不是还要去下载SDK?如果是amandag(高歌)可否给个链接?辛苦了,谢谢。