摘要: Form1 form1 = new Form1(); // form1.Show();//创建非模式对话框 form1.ShowDialog();//创建模式对话框必须要关闭次窗口才能执行其它的命令//必须添加PresentationCore.dll的引用System.Windows.Visibility.Hidden; 阅读全文
posted @ 2013-04-01 19:50 Predator 阅读(151) 评论(0) 推荐(0) 编辑
摘要: /将字符串的IP地址转换为IPAddress变量 string strIP = "192.168.1.107"; IPAddress ipAddress = IPAddress.Parse(strIP); System.Windows.Forms.MessageBox.Show(ipAddress.ToString());下面的代码效果一样,但当字符串不能转换为IPAdress的时候,以下的代码不会触发异常,只是返回false;这就是区别IPAddress ipAddress=null; IPAddress.TryParse(strIP, out ipAddress); S 阅读全文
posted @ 2013-04-01 19:48 Predator 阅读(2013) 评论(0) 推荐(0) 编辑
摘要: Color colr = Color.Black; colr = Color.FromArgb(255, 0, 0); Console.Title = "输出文本框";//设置控制台的标题 Console.ForegroundColor = ConsoleColor.Yellow;//设置控制台的文本颜色 Console.WriteLine("中国人"); Console.Clear();//清屏 Console.WriteLine("外国人"); Console.Read(); 阅读全文
posted @ 2013-04-01 19:47 Predator 阅读(371) 评论(0) 推荐(0) 编辑
摘要: /// <summary> /// 产生一种 R,G,B 均大于 colorBase 随机颜色,以确保颜色不会过深 /// </summary> /// <returns>背景色</returns> Color GetControllableColor(int colorBase) { Color color = Color.Black; if (colorBase > 200) { System.Windows.Forms.MessageBox.Show("可控制颜色参数大于200,颜色默认位黑色"); } Rando 阅读全文
posted @ 2013-04-01 19:42 Predator 阅读(325) 评论(0) 推荐(0) 编辑
摘要: 只要将charNum改变就可以自定义设计生成随机数的个数。//获取验证码的代码 void GetValidateCode() { validStr = ""; Random rd = new Random(); //创建随机数对象 //产生由 charNum 个字母或数字组成的一个字符串 string str = "0123456789";//共57个字符,除 l,o,x,I,O,X,1,0 的所有数字和大写字母 for (int i = 0; i < charNum; i++) { validStr = validStr + str.Substr 阅读全文
posted @ 2013-04-01 19:39 Predator 阅读(196) 评论(0) 推荐(0) 编辑
摘要: string names = "ganqufnu"; if ( names.Contains("nu")) { Console.Write("yes"); } private static string msg; public static string Msg { get { return TestMain.msg; } set { TestMain.msg = value; } }string path = @"/Main/Src/Bin/Exe";path=path.Replace("/" 阅读全文
posted @ 2013-04-01 10:57 Predator 阅读(1499) 评论(0) 推荐(0) 编辑