编译不同命名空间的文件的命令怎么写

qlykssl 2009-11-23 01:17:59
请教如何用命令如何编译这个类
Main
using System;
using Wrox.ProCSharp;
using Wrox.ProCSharp.VenuseBank;
using Wrox.ProCSharp.JupterBank;

namespace Wrox.ProCSharp {
public class MainEntryPoint {
public void Main (string[] args){
IBankAccount venuseAccount = new SaverAccount();
IBankAccount jupterAccount = new GoldAccount ();
venuseAccount.PayIn (200m);
venuseAccount.Withdraw (100m);
Console.WriteLine( venuseAccount.ToString() );
jupterAccount.PayIn (500m);
jupterAccount.Withdraw (600m);
jupterAccount.Withdraw (100m);
Console.WriteLine ( jupterAccount.ToString() );

}
}
}
相关与MainEntryPoint的其它类是这样的
interface:IBankAccount
using System;

namespace Wrox.ProCSharp {
public interface IBankAccount {
void PayIn (decimal amount);
bool Withdraw (decimal amount);
decimal Balance {
get;
}
}
}

class:SaverAccount
using System;

namespace Wrox.ProCSharp.VenuseBank {
public class SaverAccount : IBankAccount {
private decimal balance;
public void PayIn (decimal amount) {
balance += amount;
}
public bool Withdraw (decimal amount) {
if(balance >= amount){
balance -= amount;
return true;
}
Console.WritLine( "Withdraw attempt failed!~" );
return false;
}
public decimal Balance {
get{ return balance; }
}
public override string ToString (){
return string.Format( "Venuse Bank Saver : Balance = {0,6:C}",balance );
}
}
}

class:GoldAccount
using System;

namespace Wrox.ProCSharp.JupterBank {
public class GoldAccount : IBankAccount {
private decimal balance;
public void PayIn (decimal amount) {
balance += amount;
}
public bool Withdraw (decimal amount) {
if(balance >= amount){
balance -= amount;
return true;
}
Console.WritLine( "Withdraw attempt failed!~" );
return false;
}
public decimal Balance {
get{ return balance; }
}
public override string ToString (){
return string.Format( "Jupter Bank Gold : Balance = {0,6:C}",balance );
}
}
}

书上的例子,但是我现在不知道怎么用命令行去编译这个Main,请高手指点。
...全文
69 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
qlykssl 2009-11-24
  • 打赏
  • 举报
回复
做出来了 用
csc Main.cs GoldAccount.cs SaverAccount.cs IBankAccount.cs /main:Wrox.ProCSharp.MainEntryPoint

就可以了 上面的代码Main函数没有在 public 后面写 static 哎~ 太慌张!
感谢 wuyi8808 和 rightyeah 还有谢谢大家!
qlykssl 2009-11-23
  • 打赏
  • 举报
回复
这个太复杂 看不太懂
rightyeah 2009-11-23
  • 打赏
  • 举报
回复
命名空间和编译是无关的,编译只按照文件进行的,可以把多个不同命名空间的类,编译到一个目标中
最简单的用法,就是像2楼那种:csc *.cs
复杂点的,像这样:
c:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe /out:..\WaveTang.dll /t:library /res:TreeView3Status.resources AssemblyInfo.cs automenu.cs Sizer.cs MenuToolBar.cs Watcher.cs IconDir.cs Code128.cs EAN13.cs BigNumber.cs ImagePcx.cs ChessBoard.cs TreeView3Status.cs QueueStream.cs TcpService.cs
qlykssl 2009-11-23
  • 打赏
  • 举报
回复
我是想不用VS
用CMD 来做
hhc123 2009-11-23
  • 打赏
  • 举报
回复
哎,也只能顶了
sharp_future 2009-11-23
  • 打赏
  • 举报
回复
是要运行看效果吗?这是控制台
你新建个控制台,下面建几个类(写上你的代码)
在主函数里面调用,运行就可以看效果了
wuyi8808 2009-11-23
  • 打赏
  • 举报
回复
csc *.cs
bigmingming 2009-11-23
  • 打赏
  • 举报
回复
帮顶了

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧