【C#学习(五)之委托浅探】教程文章相关的互联网学习教程文章

C#基础知识

1、面向对象、面向接口、面向方向编程的区别:面向对象:强调对具有相同行为和属性事物的封装,更注重封装的完整性和功能的完整性面向接口:定义要实现某类功能要实现的统一规范,而具体实现过程由实现该接口的类型决定面向方面:主要提供与业务逻辑无关的操作。比如系统中多个地方要使用到的文件上传功能,可以使用面向方向的思想在所有上传文件之前对文件的大小、格式等信息进行过滤操作,而不是在每处上传代码里面完成对这些信息...

C#结课报告

Revision HistoryDateIssueDescriptionAuthor18/May/2015v1.0Initial creation岳远志 To-do-list 1.object简单的Todolist,可以新建或打开任务列表,更改任务列表名称,查看任务内容并修改,新建或删除任务2.scope适合于需要规划时间的人3.reference无 3.functionality1.可以新建或打开任务列表2.可更改任务列表名称3.可查看任务列表中已有任务的内容并修改4.可新建或删除任务5.程序退出后信息得到保存,以便下次查看或更...

C#:使用Twain协议实现扫描仪连续扫描【代码】【图】

如果用Twain协议实现一次扫描多张图片?相信有接触过Twain协议与扫描仪通信的朋友都遇到过这样的问题。按照网上的例子,在连续送纸的扫描仪中,调用一次却只能扫描一张图片,怎么破? 关于这个问题 我研究了好久,终于在困扰了我7天之后,我搞定了,下面分享一下我的解决经验。 新建一个ScanCommon类,在调用界面,写下调用扫描的方法: 1    ScanCommon scan = new RS_ScanCommon(fileName, this.Handle); 2 sca...

【C#公共帮助类】 Log4net 帮助类【代码】【图】

首先,我们要在Common类库中引用log4net.dllExtLogImpl.csusing System; using System.Collections.Generic; using System.Linq; using System.Text; using log4net.Core;namespace log4net.Ext {publicclass ExtLogImpl : LogImpl, IExtLog{///<summary>/// The fully qualified name of this declaring type not the type of any subclass.///</summary>privatereadonlystatic Type ThisDeclaringType = typeof(ExtLogImpl);publ...

C#中HTML/XML处理及正则表达式【代码】【图】

HTML Parser 一个比较方便的html解析package是HtmlAgilityPack,可以按照如下图显示在Visual Studio中安装。 使用该包的一个简单实例代码如下:publicstaticboolCrawlCategoryReviewInfo(string categoryUrl){var resp = HttpUtils.GetResponseData(categoryUrl);if (resp == null){logger.Info("Failed to request the category page from Suning server!");returnfalse;}HtmlDocument document = new HtmlDocument();document.L...

C#字符串基础【代码】

static void Main(string[] args){//How to run C# in VS Code?/*step 0: create a null folder and open it in vscodestep 1: dotnet new consolestep 2: dotnet restorestep 3: dotnet run*/Console.WriteLine("Hello World!");//////////////////////////////////////Common string is unchangable string str = "hello//:www.world.edu.uk";int result = str.CompareTo("hello");//return 0 when 2 strings are the sameresult...

C# 识别url是否是网络路径

#region 识别urlStr是否是网络路径/// <summary>/// 识别urlStr是否是网络路径/// </summary>/// <param name="urlStr"></param>/// <returns></returns>public static bool UrlDiscern(string urlStr){if (Regex.IsMatch(urlStr, @"((http|ftp|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\&%_\./-~-]*)?")){return true;}else{return false;}}#e...

C#版BitStream 1.0【代码】

根据C++版的改编,刚刚改完,估计使用会有问题,对于uint8处理的不好关于使用:1 BitStream bs = new BitStream( ); 2 bs.WriteInt32( 123 ); 34int a = bs.ReadInt32( );非常简单BitStream.cs 1publicclass BitStream2 {3#if __BITSTREAM_BIG_END4// Set up the read/write routines to produce Big-End network streams. 5privatestaticreadonlyint B16_1 = 0;6privatestaticreadonlyint B16_0 = 1;7 8priv...

C#字符串string和内存流MemoryStream及比特数组byte[]

原文:http://hi.baidu.com/endyli/item/7bf074945de35e1f934f41fe定义string变量为str,内存流变量为ms,比特数组为bt1.字符串转比特数组(1)byte[] bt=System.Text.Encoding.Default.GetBytes("字符串");(2)byte[] bt=Convert.FromBase64String("字符串");2.字符串转流(1)MemoryStream ms=new MemoryStream(System.Text.Encoding.Default.GetBytes("字符串"));(2)MemoryStream ms=new MemoryStream(Convert.FromBase64String("字符串...

C#学习日志 day 3 ------ 基本语句示例

写c#首先需要知道的就是数据类型,这里是所有c#中的所有数据类型以及说明。 放在这里方便以后查看。赋值语句老师强调一定要值域小的变量赋值给值域大的变量,否则会出问题。变量声明则个人感觉和java差不多。int a = 10;string b = "你好";而类的声明则是class c = new class(参数);上课时,我发现了一个有趣的东西,就是{0}编译后是这样的这里可以看见,这个{0}是一个占位符,类似于c语言里的输入输出格式。而WriteLine()也支持像...

C# 自定义类中括号取值 测试【代码】

publicclass ABC : Hashtable{}staticclass Program{publicstatic ABC a= new ABC();staticvoid Main(string[] args){var c = a["0"]; //自定义类中括号取值 }} var t = Request.Form["sets"].ToString();publicabstractclass HttpRequest{publicabstractIFormCollectionForm { get; set; }}publicinterfaceIFormCollection : IEnumerable<KeyValuePair<string, StringValues>>, IEnumerable{StringValues this[string key...

C#模板设计模式使用和学习心得【图】

模板设计模式:模版方法模式由一个抽象类和一个(或一组)实现类通过继承结构组成,抽象类中的方法分为三种: 抽象方法:父类中只声明但不加以实现,而是定义好规范,然后由它的子类去实现。 模版方法:由抽象类声明并加以实现。一般来说,模版方法调用抽象方法来完成主要的逻辑功能,并且,模版方法大多会定义为final类型,指明主要的逻辑功能在子类中不能被重写。 钩子方法:由抽象类声明并加以实现。但是子类可以去扩展,子类可...

不一样的风格,C#的lambda表达式【代码】

下面贴出代码using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Lambda表达式 {class Program{staticvoid Main(string[] args){//lambda表达式的演变过程//下面是C#1.0中创建委托实例的代码Func<string, int> delegatetest1 = new Func<string, int>(callbackmethod);////C#2.0中用匿名方法来创建委托实例,此事就不需...

C#整理1——进制转换

进制转换:二进制,八进制,十进制,十六进制。(一)二进制转十进制:1.写2 2.标指数,从右向左,从0开始依次标记3.乘系数,一一对应。4.相加。例:二进制数1101转十进制数*1.2 2 2 22.2^3 2^2 2^1 2^03.1*2^3 1*2^2 0*2^1 1*2^04.1*2^3+1*2^2+0*2^1+1*2^0=13(二)十进制转二进制:除2取余1.用竖式,对十进制数依次除2,记录每一步余数。2.一直除到商0为止,从下到上记录余数,即是二进制数。(三)八进制转十...

C# 页面设置成UTF-8编码格式,中文乱码问题

在.aspx页面可以设置编码格式为UTF-8,也可以再.aspx.cs后台代码设置(Response.Charset = "UTF-8"),刚开始以为这样OK了,那只调试的时候还是乱码。原来还要在Web.config里面设置,在<system.web>节点里面添加"<globalization requestEncoding="utf-8" responseEncoding="utf-8" />" 这个节点就OK了。原文:http://www.cnblogs.com/shawnY/p/3835382.html