有一个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#,谢谢!
public class Hello
{
public static void Main()
{
System.Console.WriteLine("Hello, World!");
}
}
我在命令提示符下输入
D:\cs\csc hello.cs
提示不是内部或外部命令,具体的方法该如何运行程序呢?好象是先csc hello.cs生成一个.exe文件,哪位兄弟给具体的讲一下,小弟刚学C#,谢谢!
解决方案 »
- [IE编程]MIME过滤导致flash被阻止如何解决?
- 【高分急求】如何让一个窗体(.aspx)的值传到另一窗体(.aspx)?
- 用webrequest循环检测网址是否有效的问题
- GridView问题,如果其中的AnswerE为空RadioButton5怎样让他不显示。
- 关于EXCEL导入SQL的问题
- windowsForm中数据导入过程需要很时间,怎样做一个进度给用户?
- c#发传真的代码,报对象标识符没有表示一个有效的对象的错误?
- TreeView的问题+在线给分
- MS Project 外接编程问题
- 利用c#如何实现程序的开机自动运行
- C#文本搜索
- 用WebResponse时怎么知道是500还是503错误?
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);
}
}
}
不行就到csc所在目录编译
运行了说找不到aspnet_regiis组件,该如何解决?
然后进入你文件所在目录
再通过csc hello.cs编译成exe文件,就可以执行了.
要不的你就得安装c#编译器