2012年10月26日
摘要: 可以把C#的property机制看成是C#在语言层面上对数据的封装。在使用Property时,可以把它当做一个Field使用。传统的C++中使用的方法类似于: 1 using System; 2 3 public class Customer 4 { 5 private int m_id = -1; 6 7 public int GetID() 8 { 9 return m_id;10 }11 12 public void SetID(int id)13 {14 m_id = id;15 }16 17 ... 阅读全文
posted @ 2012-10-26 15:47 Jiang, X. 阅读(359) 评论(0) 推荐(0) 编辑
摘要: 1 using System; 2 3 public class DrawingObject 4 { 5 public virtual void Draw() 6 { 7 Console.WriteLine("I'm just a generic drawing object."); 8 } 9 }10 11 using System;12 13 public class Line : DrawingObject14 {15 public override void Draw()16 {17 Console.Write... 阅读全文
posted @ 2012-10-26 15:18 Jiang, X. 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 1 using System; 2 3 public class Parent 4 { 5 string parentString; 6 public Parent() 7 { 8 Console.WriteLine("Parent Constructor."); 9 }10 public Parent(string myString)11 {12 parentString = myString;13 Console.WriteLine(parentString);14 }15 ... 阅读全文
posted @ 2012-10-26 15:15 Jiang, X. 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 1 // Namespace Declaration 2 using System; 3 4 // helper class 5 class OutputClass 6 { 7 string myString; 8 9 // Constructor10 public OutputClass(string inputString)11 {12 myString = inputString;13 }14 15 //this指向特定对象,它产生了对自己带参构造函数的调用16 public OutputClass() : t... 阅读全文
posted @ 2012-10-26 15:06 Jiang, X. 阅读(9460) 评论(0) 推荐(1) 编辑
摘要: 关键字依然是bool, 只是其值只有true,false,没有0,1。这算是一种严格的语言定义吧。使用控制台打印bool得到的是“True”,“False”。 阅读全文
posted @ 2012-10-26 14:20 Jiang, X. 阅读(2786) 评论(0) 推荐(0) 编辑
摘要: 今天学到了C#中的{n}运算符,感觉这个运算符就是对C++中%d运算符的一种改进,因为{n}运算符能够指定替换列表中的第几个,就比%d之类的运算符操作起来省力很多。我的例程: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace braceApplication 7 { 8 class Program 9 {10 static void Main(string[] args)11 {1... 阅读全文
posted @ 2012-10-26 12:00 Jiang, X. 阅读(475) 评论(0) 推荐(0) 编辑
摘要: 昨天在别人的电脑上成功运行了上次我写的打印预览程序,但是今天换了一台电脑就不能运行了,让我觉得非常奇怪。提示的错误信息是“内存XXXX不能为read”,“mfc100d.dll”中有未经处理的异常。奇怪的是,我加了try catch语句后依然出错。我首先尝试了dll链接和动态链接,发现仍然无法解决。然后我尝试了在网上下载mfc100.dll,拷贝到system32目录下,依然出错。由于这种问题我基本上可以确定是操作系统环境的问题,于是我搜索了“电脑不能打印预览解决方法”,发现可能是打印机没有安装驱动或者是打印服务没有启动,于是:一、启动打印服务:右击“我的电脑”\“管理”\"服务和应 阅读全文
posted @ 2012-10-26 10:46 Jiang, X. 阅读(1445) 评论(1) 推荐(0) 编辑
摘要: GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_HIDE);GetDlgItem:通过ID得到窗口的句柄GetDlgItem functionApplies to:desktop apps onlyRetrieves a handle to a control in the specified dialog box.SyntaxC++HWND WINAPI GetDlgItem( _In_opt_HWND hDlg, _In_int nIDDlgItem);ParametershDlg[in, optional]Type:HWNDA handle to th 阅读全文
posted @ 2012-10-26 08:54 Jiang, X. 阅读(1160) 评论(0) 推荐(0) 编辑