有一个C#文件hello.cs,放在D盘的test文件夹下,其源代码如下:
    public class Hello
    {
      public static void Main()
      {
         System.Console.WriteLine("Hello, World!");
      }
    }
我在命令提示符下输入
D:\cs\csc hello.cs
提示不是内部或外部命令,具体的方法该如何运行程序呢?好象是先csc hello.cs生成一个.exe文件,哪位兄弟给具体的讲一下,小弟刚学C#,谢谢!

解决方案 »

  1.   

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Text.RegularExpressions;
    using System.Resources;
    using System.Globalization;
    using System.Reflection;
    using TrainingProject.Entity;
    using TrainingProject.BizLogic;
    using TrainingProject.DataAccess;
    using System.Threading;
    using System.IO;
    using System.Web;
    using System.Drawing;
    using System.Drawing.Imaging;namespace TrainingProject.BizLogic
    {    
        /// <summary>
        /// All web page inherit the class.
        /// </summary>
        public class BasePage : System.Web.UI.Page, IHttpHandler
        {        
            /// <summary>
            /// Judge user if has login in system
            /// </summary>
            public void HasLogin()
            {
                if(Session["UserID"] == null)
                {
                    Response.Redirect("Login.aspx");
                }
            }
            
            /// <summary>
            /// Judge a user if has access
            /// </summary>
            /// <param name="isAdmin">if is a admin</param>
            public void HasAccess(bool isAdmin)
            {
             bool access = false;
             UserBiz userBiz = new UserBiz();
             UserInfo user = userBiz.GetUserByID(Convert.ToInt32(Session["UserID"].ToString()));
             if(user.Role == 1)
             {
             if(!isAdmin)
             access = true;
             }
             else
             {
             if(isAdmin)
             access = true;
             }
            
             if(access)
             Response.Redirect("Default.aspx");
            }
            
            /// <summary>
            /// Get the value from resource file by key.
            /// </summary>
            /// <param name="key">The key in the resources file.</param>
            /// <returns>The value from resources file.</returns>
            public string GetString(string key)
            {            
                string result = "";
                ResourceManager resourceManager = null;
                CultureInfo culture = null;
                
                try
                {  
                 if(Session["Culture"] != null)
                 {
                 culture = new CultureInfo(Session["Culture"].ToString());
                 Thread.CurrentThread.CurrentCulture = culture;
                 Thread.CurrentThread.CurrentUICulture = culture;
             resourceManager = new ResourceManager("strings", Assembly.GetExecutingAssembly());
                     
             result = resourceManager.GetString(key, culture);               
                 }
                
                }
                catch(Exception e)
                {
                    throw e;
                }            
                
                return result;
            }
            
            /// <summary>
            /// Generate java script
            /// </summary>
            /// <param name="message">message to show</param>
            /// <returns></returns>
            public string AlertMessageBox(string message)
            {
                string temp = "<script>" + Environment.NewLine;
                temp += "alert('" + message +"')" + Environment.NewLine;
                temp += "</script>";
                
                return temp;
            }
            
            /// <summary>
            /// Enum of user role
            /// </summary>
            public enum Role
            {
             /// <summary>
             /// Admin 1,
             /// </summary>
             Admin = 1,
             /// <summary>
             /// Customre 2
             /// </summary>
             Customer = 2
            }
            
            /// <summary>
            /// Set session's out time
            /// </summary>
            public void SetTimeOut()
            {
                Response.Write("<SCRIPT LANGUAGE='Javascript'><!--" + Environment.NewLine);
                Response.Write("var timeOut=" + Convert.ToString(Session.Timeout*60) + "; var count=1; window.setTimeout('startClock()', 1000);" + Environment.NewLine);
                Response.Write("function startClock() { " + Environment.NewLine);
                Response.Write("timeOut=timeOut-count; window.setTimeout('startClock()', 1000);" + Environment.NewLine);
                Response.Write("if (timeOut==0) { " + Environment.NewLine);
                Response.Write("alert('" + GetString("SessionTimeOut") + "'); window.open('Login.aspx', '_self'); }" + Environment.NewLine);
                Response.Write(" } " + Environment.NewLine);
                Response.Write("//--></SCRIPT>" + Environment.NewLine);
            }
        }
    }
      

  2.   

    在命令行运行一下aspnet_regiis -c看看
    不行就到csc所在目录编译
      

  3.   

    打开VS.NET的命令行窗口,然后在这个终端中去运行你的程序即可。
      

  4.   

    你的运行的意思是不是编译?如果是请参考SDK说明,
      

  5.   

    在命令行运行一下aspnet_regiis -c看看~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    运行了说找不到aspnet_regiis组件,该如何解决?
      

  6.   

    我的意思就是想不用visual studio .net这个工具,据说这样可以理解代码更透彻点,对以后编程有好处
      

  7.   

    点击  Visual Studio .NET 工具  -->Visual Studio .NET 2003 命令提示 进入dos界面
    然后进入你文件所在目录
    再通过csc hello.cs编译成exe文件,就可以执行了.
      

  8.   

    这样做的前题是你安装了Visual Studio .NET
    要不的你就得安装c#编译器