C#
文章平均质量分 58
sinat_15155817
生命在于运动
展开
-
params 长度可变参数
调用:Sum("aaa",6,7,4,9);说明 params 参数必须位于所有参数的最后static int Sum(string str, params int[] nums) { var sum = 0; foreach (var num in nums) {原创 2015-09-19 20:59:49 · 339 阅读 · 0 评论 -
集合已修改;可能无法执行枚举操作
使用foreach不能执行删除、修改,这是规定。你可以使用for循环遍历修改。如果你是删除的话,for循环 i 要从大到小,比如:for(int i=50;i>=0;i--){ }原创 2017-04-24 22:25:14 · 2335 阅读 · 0 评论 -
TabIndex
控件的 TabIndex 属性设置键盘中的TAB键在控件中的移动顺序,即焦点的顺序。把控件的tabIndex属性设成1到32767的一个值,就可以把这个控件加入到TAB键的序列中。这样,当浏览者使用TAB键在网页控件中移动时,将首先移动到具有最小tabIndex属性值的控件上,最后在具有最大tabIndex属性值的控件上结束移动。如果有两个控件的tabIndex原创 2017-04-24 22:30:44 · 1951 阅读 · 0 评论 -
C# 16进制与字符串、字节数组之间的转换
string转byte[]:byte[] byteArray = System.Text.Encoding.Default.GetBytes ( str );byte[]转string:string str = System.Text.Encoding.Default.GetString ( byteArray );string转ASCII byte[]:b转载 2017-06-15 16:35:03 · 315 阅读 · 0 评论 -
C#委托的基本使用
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace Windo原创 2017-09-17 09:50:22 · 223 阅读 · 0 评论 -
C# 利用BarcodeLib.dll生成条形码(一维,zxing,QrCodeNet/dll二维码)
原文:http://blog.csdn.net/kongwei521/article/details/17588825 首先效果:一、下载BarcodeLib.dll下载地址 :http://download.csdn.net/detail/lllooollpp/7961715 源码:https://github.com/hjgode/barcodeLib1.Bar原创 2017-11-17 14:33:36 · 9992 阅读 · 0 评论 -
泛型总结
1.以下代码中的show方法,object 和泛型的输出结果完全相同,但是我们尽量要用泛型,因为object 参数在进行传入的时候,会进行装箱和拆箱,这样效率会变慢,而泛型实质是语法糖。它是编译器提供的功能,在调用的生成对应的副本,例如:泛型传入的类型是int它会生成对应的 public void Show(int t){}方法,泛型编译后是 Show~1(); public原创 2017-11-15 22:53:12 · 136 阅读 · 0 评论 -
反射的总结
1.反射的可扩展性,可以把要加载的dll文件放在App.config中 2.使用反射创建对象并调用方法 private void button1_Click(object sender, EventArgs e) { var assembly = Assembly.Load("Conso原创 2017-11-16 00:02:36 · 151 阅读 · 0 评论 -
C# Winform应用程序占用内存较大解决方法整理(转)-- SetProcessWorkingSetSize
一、C# Winform应用程序占用内存较大解决方法整理(转)原文: http://www.jb51.net/article/56682.htm背景:微软的 .NET FRAMEWORK 现在可谓如火如荼了。但是,.NET 一直所为人诟病的就是“胃口太大”,狂吃内存,虽然微软声称 GC 的功能和智能化都很高,但是内存的回收问题,一直存在困扰,尤其是 winform 程序,其主要原因原创 2017-11-16 23:31:17 · 7185 阅读 · 0 评论 -
SQL Help
namespace dal { public class SQLHelper { private SqlConnection conn = null; private SqlCommand cmd = null; private SqlDataReader sdr = null;原创 2016-10-18 17:09:52 · 377 阅读 · 0 评论 -
Asp.net .net(C#) 获取当前命名空间,类名,方法名的方法
Asp.net .net(C#) 获取当前命名空间,类名,方法名的方法public static string GetMethodInfo(){ string str = ""; //取得当前方法命名空间 str += "命名空间名:"+System.Reflection.MethodBase.GetCurrentMethod().Declari转载 2018-01-09 21:29:42 · 1818 阅读 · 0 评论 -
无法评估表达式,因为当前线程处于堆栈溢出状态。
public DevExpress.XtraEditors.XtraScrollableControl XtraScrollableControl { get { return this.XtraScrollableControl; } } public DevExpress.XtraEditors.XtraScroll原创 2018-01-10 10:18:25 · 1887 阅读 · 0 评论 -
C# 真正完美的 汉字转拼音
原文地址:http://www.cnblogs.com/shikyoh/p/6270026.htmlC# 真正完美的 汉字转拼音网上有很多说自己整理的汉字转拼音是完美的,但使用后才发现都是半吊的瓶子,问题多多。常见的生僻字,或多音字识别,转换后简直让人感觉可怕。主流的转换有三种:hash匹配,Npinyin,微软PinYinConverter。但单用这三个,都没转载 2018-02-03 18:35:43 · 2074 阅读 · 0 评论 -
定时器经典
static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { ...原创 2018-05-10 23:18:29 · 211 阅读 · 0 评论 -
自定义屏幕保护
一、设计器页面及代码(Form2.Designer.cs):namespace 自定义屏保{ partial class Form2 { /// /// Required designer variable. /// private System.ComponentModel.IContainer com原创 2017-04-16 19:04:43 · 956 阅读 · 0 评论 -
LoaderException的解决方法
原文地址:http://www.cnblogs.com/3echo/archive/2007/12/03/980878.html一、问题描述:利用反射机制得到程序集的所有类型,常常会出现下面的问题。代码如下:Assembly pAssembly = System.Reflection.Assembly.LoadFile(pfilepath);Type[] pTypes转载 2017-01-03 19:38:47 · 3447 阅读 · 0 评论 -
不用中间变量,实现两个变量的交换
常见的面试题,很简单,但值得细想的问题还是很多,总结解法如下:(1)加减法: int a =10,b=5; a = a+b; b = a-b; a = a-b; System.out.println("a=" + a); System.out.println("b=" + b); 原理:其实转载 2017-01-03 19:36:55 · 773 阅读 · 0 评论 -
可空数据类型 和 随机数
一、在编程时候,经常会遇到 某一对象或者变量为 null那么那些类型可以为空呢,不可为空的类型怎么让其可以为空呢可空数据类型:引用类型、自定义类、string、大部分类的对象都可以为null不可以为空类型:int 、boolean、decimal、DateTime、float、double 等。列入: int num = null;原创 2015-09-20 08:23:23 · 571 阅读 · 0 评论 -
关于BLL DAL MODEL的小问题
UI 表示层 :就是我们看到的网站前台BLL 业务逻辑层:很简单 也很重要 处理逻辑问题 简单程序看不出啥效果DAL 数据访问层: 写数据连接和执行的SQL语句MODEL 模型层:封装数据库文件DAL引用MODEL BLL引用 DAL 和 MODEL UI引用BLL和MODEL 分层好维护 也好修改原创 2015-10-13 21:19:32 · 338 阅读 · 0 评论 -
C#中as用法总结
在程序中,进行类型转换时常见的事,C#支持基本的强制类型转换方法,例如Object obj1 = new NewType();NewType newValue = (NewType)obj1;这样强制转换的时候,这个过程是不安全的,因此需要用try-catch语句进行保护,这样一来,比较安全的代码方式应如下所示:Object obj1 = new NewType();NewTy转载 2015-12-31 11:01:49 · 647 阅读 · 0 评论 -
文件操作
原创 2016-05-29 15:50:31 · 303 阅读 · 0 评论 -
C#判断ip地址是否可以ping的通
Ping pingSender = new Ping(); PingReply reply = pingSender.Send("127.0.0.1",120);//第一个参数为ip地址,第二个参数为ping的时间 if(reply.Status == IPStatus.Success) { //ping的通 } else { //ping不通 }转载 2016-05-20 16:51:20 · 2266 阅读 · 2 评论 -
ASP.NET跨页面传值技巧总结
原文地址:ASP.NET页面传值关于页面传值的方法,引发了很多讨论。看来有很多人关注这个,我就我个人观点做了些总结,希望对大家有所帮助。 1. 使用QueryString变量 QueryString是一种非常简单的传值方式,他可以将传送的值显示在浏览器的地址栏中。如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法。但是对于传递数组或对象的话,就不能原创 2016-08-30 14:38:57 · 2014 阅读 · 0 评论 -
ASP.NET网络编程中经常用到的27个函数集
1、DateTime 数字型 以下是引用片段: System.DateTime currentTime=new System.DateTime(); 1.1 取当前年月日时分秒 currentTime=System.DateTime.Now; 1.2 取当前年 int 年=currentTime.Year; 1.3 取当前月 int 月=currentTime.Mont转载 2016-08-30 15:03:36 · 220 阅读 · 0 评论 -
ASP.NET开发在线编辑器模块实战开发
1、FreeTextBox在asp.net下的使用,2、FreeTextBox在IE8下面异常,3、FCKeditor在asp.net中的使用,4、FCKeditor在MVC3中的使用,5、kindeditor在asp.net中的使用点击打开链接原创 2016-08-21 11:09:18 · 507 阅读 · 0 评论 -
生成随即字符验证码
using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.W原创 2016-09-06 09:45:09 · 282 阅读 · 0 评论 -
sqlserver数据库的image字段存入方法 ,读取
存入方法private void button1_Click(object sender, EventArgs e) { openFileImage.Filter = "*.jpg|*.JPG|*.gif|*.GIF|*.bmp|*.BMP"; if (openFileImage.ShowDialog() == DialogRe原创 2016-09-23 14:05:42 · 28523 阅读 · 3 评论 -
上传下载功能
这个是上传文件:http://www.cnblogs.com/xiaozhuang/archive/2008/04/01/1133138.html这个是下载文件:http://www.cnblogs.com/qldsrx/archive/2012/04/08/2437583.html转载 2016-12-14 10:44:39 · 244 阅读 · 0 评论 -
C#如何使用反射实现通过字符串创建类
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ReflectFromStringToClass{ class Program { static void Main(string[] args) {原创 2017-01-03 17:09:09 · 1713 阅读 · 0 评论 -
C# .Net动态调用webService (转载)
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Net;using System.IO;using System.Web.Services.Description;using System.CodeDom;using Microsoft.CSh转载 2017-01-03 17:18:13 · 526 阅读 · 0 评论 -
DataTable 增加列并赋值
DataTable dt = new DataTable(); dt.Columns.Add("a", typeof(int)); for (int i = 0; i < 10; i++) { dt.Rows.Add(); dt.Rows[i][0] = i; } ...原创 2018-06-21 17:55:39 · 15839 阅读 · 1 评论