随笔分类 - C#
摘要:Console.WriteLine(DBNull.Value.ToString() == string.Empty); //True
阅读全文
摘要:params参数支持数组作为参数传入,但并不支持List 定义一个使用params的参数 运行结果: 可以看到,null是可以作为参数传入的,所以使用params参数的方法最好是进行null判断:
阅读全文
摘要:添加System.Web.dll引用添加System.Net.Http引用 using System.Net.Http; using System.Web; string key = "电脑"; //拼音diannao也可 string url = string.Format...
阅读全文
摘要:看到代码里有用位操作来判断条件的,以前没有这么用过,做个笔记: int add = 2; int modify = 4; int delete = 8; Console.WriteLine((add | modify | delete) & add); //2 Cons...
阅读全文
摘要:通过InternalsVisibleToAttribute可以将源程序集的internal成员暴露给指定的友元程序集
阅读全文
摘要:C#中规定:如果程序的控制流进入了一个带finally块的try语句,那么finally语句块始终会被执行例子:class Program { static void Main(string[] args) { Console.WriteLin...
阅读全文
摘要:一、如何用VS创建Windows服务1、新建C# Windows服务:windows service工程2、新建windows service工程后,系统自动生成一个Service1.cs文件,默认是其设计视图。选择查看其代码,默认有构造函数、OnStart、OnStop三个函数3、新建了C# Wi...
阅读全文
摘要:StringBuilder output = new StringBuilder();String xmlString = @" The Autobiography of Benjamin Franklin Benjamin ...
阅读全文
摘要:privatestringGetMd5(StreamfileStream){MD5CryptoServiceProvidermd5Provider=newMD5CryptoServiceProvider();byte[]bytesHash=md5Provider.ComputeHash(fileSt...
阅读全文
摘要:思路是通过WebRequest连接一些网上提供IP查询服务的网站,下载到含有你的IP的网页,然后用正则表达式提取出IP来class Program { static void Main(string[] args) { Console.Writ...
阅读全文
摘要:static void Main(string[] args) { string IPs = " 192.168.1.1 202.47.4.6 1.2.3.3 "; Console.WriteLine(I...
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Text.RegularExpressions;using System.Net;using System.I...
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Diagnostics;using System.Text.RegularExpressions;namesp...
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net.Mail;using System.Net.Mime;using System.IO;using Sy...
阅读全文
摘要:方法不是很好。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.Text.RegularExpressions;namespa...
阅读全文
摘要:参考了网上的文章,具体地址不记得了。下面的方法可以过滤掉虚拟机的网卡等无效网卡,进而只留下真实的网卡。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Mana...
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Management;namespace _17获取MAC地址{ class Program { ...
阅读全文
摘要:照着书敲的。留作笔记吧。using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Runtime.InteropServices;namespace _18获取本机磁盘...
阅读全文
摘要:实际是通过c#编程方式调用了CMD命令行,然后调用netstat命令,然后将CMD命令的输出流转到了C#控制台程序上。也可以将结果输出到文件。using System;using System.Collections.Generic;using System.Linq;using System.Te...
阅读全文
摘要:代码是照着书敲的,贴出来方便平时参考using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net.NetworkInformation;namespace _20通...
阅读全文