//[<] //[@yymmdd:hh:mm] //[#Number] //[&Language] //[$Technique] //[keywords] // "//[" and "//~" will be detected //[>] < and > means comments, chars outside square brackets will be ignored //[@20180715] //[@20180715:22:39]:[#1]:[&C#][$WindowsFormsApp] //[Check if object is disposed][检查对象是否已经释放] try {} catch (System.ObjectDisposedException) {} //~[#1] //[@20180715:22:42]:[#2]:[&C#][$WindowsFormsApp] //[Add click event on form][添加点击窗体事件] public Form1() { InitializeComponent(); fm = new Form2(); this.FormClosing += Form1_Closing; this.Click += Form1_Click; } //~[#2] //~[@20180715] //[@20180716] //[@20180716:12:37]:[#1]:[&C#][$WindowsFormsApp] //[Image.FromFile(string) will lock file][pictureBox用FromFile方法加载图片会锁住文件] FileStream fstrm = new FileStream(imageURL, FileMode.Open, FileAccess.Read); pictureBox1.Image = Image.FromStream(fstrm); //Close method will unlock the file fstrm.Close(); //~[#1] //[@20180716:12:40]:[#2]:[&C#][$WindowsFromsApp] //[Open current directory in exlorer][在windows文件浏览器中打开当前文件夹] System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.UseShellExecute = true; process.StartInfo.FileName = @"explorer"; process.StartInfo.Arguments = Directory.GetCurrentDirectory(); process.Start(); //~[#2] //[@20180716:13:59]:[#3]:[&C#][$using statement] //[using statement will dispose <Variablename> when code block is done] //[使用using可以自动销毁变量,C#会自动调用 Dispose()] using (<ClassName> <VariableName> = new <ClassName>()) { ... } //~[#3] //~[@20180716] //[@20180717] //[@20180717:23:55]:[#1]:[&C#][$string substring] //[how to use stirng.substring method][string类substring方法] //Example: Get parent dirctory string public String test(String str) { // C:\a\b\c\d\\ => C:\a\b\c => C:\a\b .. str=str.Substring(0,str.LastIndexOf(str,'\\')); return str; } //~[#1] //~[@20180717]
[ C# ] C# 学习笔记 [ 持续更新 ]
猜你喜欢
转载自www.cnblogs.com/Gster/p/9315275.html
今日推荐
周排行