menu

秋梦无痕

一场秋雨无梦痕,春夜清风冻煞人。冬来冷水寒似铁,夏至京北蟑满城。

Avatar

使用项目属性Tips and tricks

from: Doggy 的 .NET 之路

Working with C# - Tips and Tricks

1. Windows Froms和the Console Window的区别就是Console应用程序默认把输出送到Console,而Windows程序不这么做。这并不意味着Windows程序不能这么做。打开项目属性,把output type从Windows Application改成Console Application. 或者命令行中用/target:exe代替/target:winexe。

2. 写C#代码时常用到XML文档的特性,例如:

class Vector {
/// <summary>
/// Compute the length of the vector
/// </summary>
public double Length {
get {
return(Math.Sqrt(x * x + y * y));
}
}
}

在后面写下面代码时,可以看到一个弹出窗口,自动完成Length,然后显示信息Compute the length of the vector。

double l = v.Length;

但是如果把这个类编译成库,在别的项目中引用时,就没有这个提示了。

改变的办法是生成单独的XML文档。修改类库的项目属性,配置属性给XML文档文件一个文件名。一般把生成的类库文件后面dll换成xml就可以了。命令行中可以使用/doc参数。

评论已关闭