一些很酷的.Net技
2009-04-21 22:19 观海看云 阅读(91) 评论(0) 编辑 收藏 举报 一..Net Framework 1 使用System.Envioment Environment.GetFolderPath( Environment.SpecialFolder.Personal ) 2 1 2 3 使用Envioment OperatingSystem os = Environment.OSVersion; MessageBox.Show(os.Version.ToString()); MessageBox.Show(os.Platform.ToString()); 4 使用System.IO.Path 5 使用System.IO.Path.GetExtension 6 7 使用System.Windows.Forms. SystemInformation 8 标示当前程序使用单线程的方式运行 9 通过OdbcConnection 创建连接之后就可以使用DataAdapter 详细信息见此处 10. public sealed class DriveInfo { [DllImport("kernel32.dll", EntryPoint = "GetDiskFreeSpaceExA")] private static extern long GetDiskFreeSpaceEx(string lpDirectoryName, out long lpFreeBytesAvailableToCaller, out long lpTotalNumberOfBytes, out long lpTotalNumberOfFreeBytes); public static long GetInfo(string drive, out long available, out long total, out long free) { return GetDiskFreeSpaceEx(drive, out available, out total, out free); } public static DriveInfoSystem GetInfo(string drive) { long result, available, total, free; result = GetDiskFreeSpaceEx(drive, out available, out total, out free); return new DriveInfoSystem(drive, result, available, total, free); } } public struct DriveInfoSystem { public readonly string Drive; public readonly long Result; public readonly long Available; public readonly long Total; public readonly long Free; public DriveInfoSystem(string drive, long result, long available, long total, long free) { this.Drive = drive; this.Result = result; this.Available = available; this.Total = total; this.Free = free; } } 可以通过DriveInfoSystem info = DriveInfo.GetInfo("c:"); 11 1 string strParent = "The Codeproject site is very informative."; string strChild = "codeproject"; // The line below will return -1 when expected is 4. int i = strParent.IndexOf(strChild); // The line below will return proper index int j = strParent.ToLower().IndexOf(strChild.ToLower()); 2) using System.Globalization; string strParent = "The Codeproject site is very informative."; string strChild = "codeproject"; // We create a object of CompareInfo class for a neutral culture or a culture insensitive object CompareInfo Compare = CultureInfo.InvariantCulture.CompareInfo; int i = Compare.IndexOf(strParent,strChild,CompareOptions.IgnoreCase); 二. OOPs 1. 我们知道构造函数是用来初始化我们要创建实例的特殊的方法。通常我们要将一个实例赋值给另外一个变量c# 我们可以为类创造 public Student(Student student) { this.name = student.name; } 使用上面的构造函数我们就可以复制一份新的实例值,而非赋值同一引用的实例了。 class Student { private string name; public Student(string name) { this.name = name; } public Student(Student student) { this.name = student.name; } public string Name { get { return name; } set { name = value; } } } class Final { static void Main() { Student student = new Student("A"); Student NewStudent = new Student(student); student.Name = "B"; System.Console.WriteLine("The new student's name is {0}", NewStudent.Name); } } 2 就是静态的只读变量,它通常在静态构造函数中赋值。 class Numbers { public readonly int m; public static readonly int n; public Numbers(int x) { m = x; } static Numbers() { n = 100; } } //其中n就是一个只读的常量,对于该类的所有实例他只有一种值,而m则根据实例不同而不同 三.VS.Net IDE 1. 2 3 通过工具 四.WinForm 1 通过设置form form1.Text = string. Empty; form1.ControlBox = false; 2 见原作 3 设置form 4 1 <a href=”mailto:email@address1.com,email@address2.com?cc=email@address3.com&Subject=Hello&body=Happy New Year”>some text</a> 2) Process process = new Process(); process.StartInfo.FileName = "mailto:email@address1.com,email@address2.com?subject=Hello&cc=email@address3.com&bcc=email@address4.com&body=Happy New Year" ; process.Start(); 5 需要获得通过Screen.GetWorkingArea(this).Width 五.Button 1 可以设置form 2. 可以设置form 3. Button1.PerformClick 六.Combo Box 1 comboBox1.Items.AddRange (FontFamily.Families); 七.TextBox 1 textBox1.ContextMenu = new ContextMenu(); 2,3 4 textBox1.SelectionStart = textBox1.Text.Length; |
作者:观海看云(个人开发历程知识库 - 博客园)
出处:http://www.cnblogs.com/zhangtao/
文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://www.cnblogs.com/zhangtao/
文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器