第三天:
2.10控制台IO
主要关于Console.WriteLine()用法
1:
int i=10;
int j=20;
Console.WriteLine("{0} plus {1} equals {2}",i,j,i+j);
2:{n,w} n是参数索引,w是宽度值
int i=940;
int j=73;
Console.WriteLine("{0,4}\n+{1,4}\n————\n{2,4}",i,j,i+j);
还可以添加格式字符串以及可选精度值,不过这里略
2.11使用注释
2.11.1源文件的内部注释
// 与/**/ 略
2.11.2 XML文档
添加XML注释能生成XML文档
例:
//MathLib.cs
namespace Wrox{
///<summary>
///Wrox.Math class
///Provides a method to add two integers.
///</summary>
public class MathLib{
///<summary>
///The Add Method allows us to add two integers.
///</summary>
///<returns>Result of the addition (int)</returns>
///<param name="x">First number to add</param>
///<param name="y">Second number to add</param>
public int Add(int x,int y){
return x+y;
}
}
}
2.12 C#预处理命令
2.12.1 #define和#undef
感觉觉和C++差不多,略
2.12.2 #if #elif #else #endif
条件编译,与C/C++类似,#elif相当于else if,略
2.12.3 #warning和#error
#warning会产生一条警告
#error会产生错误,并退出编译
这两条主要用于检查#define是否做错事
2.12.4 #region和#endregion
用于把一段代码标记为有给定名称的一个块
不明所以,所以略
2.12.5 #pragma
可抑制或还原指定的编译警告
2.13 C#编程规则
(对程序员十分重要,不过在其它书看过N遍了,略)
3.1 创建及使用类
类很重要
3.2类和结构
类:
class A{
……
}
结构:
struct A{
……
}
类与结构很相似,都用new声明实例。较小的数据类型使用结构可提高性能。
主要不同:类存在堆上,而结构存在栈上。
类较结构常用
3.3.1数据成员
与C++/JAVA类似,就是类里的变量,略
(今天课太多了,学习时间少,70页,剩1517-70=1447 2014.12.4)
2.10控制台IO
主要关于Console.WriteLine()用法
1:
int i=10;
int j=20;
Console.WriteLine("{0} plus {1} equals {2}",i,j,i+j);
2:{n,w} n是参数索引,w是宽度值
int i=940;
int j=73;
Console.WriteLine("{0,4}\n+{1,4}\n————\n{2,4}",i,j,i+j);
还可以添加格式字符串以及可选精度值,不过这里略
2.11使用注释
2.11.1源文件的内部注释
// 与/**/ 略
2.11.2 XML文档
添加XML注释能生成XML文档
例:
//MathLib.cs
namespace Wrox{
///<summary>
///Wrox.Math class
///Provides a method to add two integers.
///</summary>
public class MathLib{
///<summary>
///The Add Method allows us to add two integers.
///</summary>
///<returns>Result of the addition (int)</returns>
///<param name="x">First number to add</param>
///<param name="y">Second number to add</param>
public int Add(int x,int y){
return x+y;
}
}
}
2.12 C#预处理命令
2.12.1 #define和#undef
感觉觉和C++差不多,略
2.12.2 #if #elif #else #endif
条件编译,与C/C++类似,#elif相当于else if,略
2.12.3 #warning和#error
#warning会产生一条警告
#error会产生错误,并退出编译
这两条主要用于检查#define是否做错事
2.12.4 #region和#endregion
用于把一段代码标记为有给定名称的一个块
不明所以,所以略
2.12.5 #pragma
可抑制或还原指定的编译警告
2.13 C#编程规则
(对程序员十分重要,不过在其它书看过N遍了,略)
3.1 创建及使用类
类很重要
3.2类和结构
类:
class A{
……
}
结构:
struct A{
……
}
类与结构很相似,都用new声明实例。较小的数据类型使用结构可提高性能。
主要不同:类存在堆上,而结构存在栈上。
类较结构常用
3.3.1数据成员
与C++/JAVA类似,就是类里的变量,略
(今天课太多了,学习时间少,70页,剩1517-70=1447 2014.12.4)
本文详细介绍了C#编程中的控制台输入输出、注释、预处理命令、类与结构的使用,以及创建和使用类的基本概念。通过具体示例,深入浅出地解释了这些核心内容。
980

被折叠的 条评论
为什么被折叠?



