摘要: //传统定义参数属性的方法public class MyClass{ private int _age; public int Age { get{ return _age; } set{ _age = value; } }}//如果get, set逻辑简单,可使用自动属性public class MyClass{ public int Age {get; set;} } 阅读全文
posted @ 2013-01-08 19:04 马语者 阅读(299) 评论(0) 推荐(0)
摘要: Close()函数只能关闭当前窗体。如果要关闭当前程序的所有窗体,可以用:Application.Current.Shutdown(); 阅读全文
posted @ 2013-01-08 18:47 马语者 阅读(6600) 评论(0) 推荐(0)
摘要: list.Sort((s1, s2)=> s1.CompareTo(s2));5.CompareTo(6) = -1 First int is smaller. 6.CompareTo(5) = 1 First int is larger. 5.CompareTo(5) = 0 Ints are equal.orderList.Sort(delegate(Order p1,Order p2){int compareDate = p1.Date.CompareTo(p2.Date);if(compareDate ==0){return p2.OrderID.CompareTo(p1.Ord 阅读全文
posted @ 2013-01-06 15:50 马语者 阅读(306) 评论(0) 推荐(0)
摘要: 在C#中 \ 是转义字符,如下所示转义序列字符\’单引号\”双引号\\反斜杠\0空\a警告\b退格\f换页\n换行\r加车\t水平制表符\v垂直制表符例如输出双引号,有以下两种方法:string str1=@"""双引号""";string str2="\"双引号\""; 阅读全文
posted @ 2013-01-04 16:46 马语者 阅读(6903) 评论(0) 推荐(0)
摘要: 获取各种路径//应用程序的当前工作目录。 System.IO.Directory.GetCurrentDirectory(); //获取程序的基目录。System.AppDomain.CurrentDomain.BaseDirectory; //获取和设置包括该应用程序的目录的名称。System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。 System.Windows.Forms.Application.StartupPath; //获取启动了应用程序的可 阅读全文
posted @ 2013-01-04 15:27 马语者 阅读(2110) 评论(0) 推荐(1)
摘要: 需要添加引用System.DiagnosticProcess process = new Process(); //创建进程对象process.StartInfo.FileName = "cmd.exe"; //要执行的程序名process.StartInfo.UseShellExecute = false; ////不使用系统外壳程序启动进程process.StartInfo.CreateNoWindow = true; //不显示dos程序窗口//重新定向标准输入,输入,错误输出process.StartInfo.RedirectStandardInput = true 阅读全文
posted @ 2013-01-04 14:22 马语者 阅读(2509) 评论(0) 推荐(0)
摘要: 横河wvf型数据,分别保存在hdr(数据信息文件)和wvf(数据文件)两个文件中。其中HDR文件格式及参数可以参考:http://www.yokogawa.com/jp-ymi/tm/TI/TIdoc/TI700021.pdf1.保存hdr中数据信息的结构体View Code //.hdr文件的wvf文件信息structpublic struct WVFInfo{ public string FileName; public string FormatVersion; public string Model; public WVFEndianType Endian; ... 阅读全文
posted @ 2013-01-04 14:10 马语者 阅读(1461) 评论(0) 推荐(0)
摘要: 使用@的意思是不转义\按说要在字符串里表示c:\windows\notepad.exe得写成c:\\windows\\notepad.exe但是前面加@以后就不用两个\了 阅读全文
posted @ 2013-01-04 13:55 马语者 阅读(5015) 评论(0) 推荐(1)
摘要: List<T> 被声明为class, 所以它是地址型变量。而值型变量会被声明为struct。在赋值时需要注意,比如:List<int> listA = new List<int>(){1, 2, 3};List<int> listB = new List<int>();List<int> listC = new List<int>();listB = listA;listC = listA;for(int i = 0; i< listB.Count; i++){ listB[i] =listC[i] *2 阅读全文
posted @ 2012-12-31 13:27 马语者 阅读(1208) 评论(0) 推荐(0)
摘要: 前面补0的数字字串String.Format("{0:0000}", 157); // 输出 0157 前后都补0的数字字串String.Format("{0:0000.0000}", 157.42); // 输出 0157.4200 每3位数(千)加逗号(String.Format("{0:0,0}", 38560); // 输出 38,5600:0 这样表示会把前面补0 ,例如本来是6,会显示06,所以不要有0: 就不会变成06格式化电话号码(String.Format("{0:(###) ###-####}" 阅读全文
posted @ 2012-12-26 17:00 马语者 阅读(3123) 评论(0) 推荐(0)