最近的项目中,因为一些原因,需要C#调用非托管(这里为C++)的动态库.网上喜闻乐见的方式是采用静态(DllImport)方式进行调用.偶然在园子里看到可以用动态(LoadLibrary,GetProcAddress,FreeLibrary)方式调用非托管动态库,于是就想着比较一下静态和动态方式的性能(主要想用运行时间来体现). 以下为源码: 1.主程序源码: using System; using System.Diagnostics; using System.Text; using Sys…
字符串是由一个个字符组成的,每个字符又有一个或多个字节来表示,每个字节又由8个bit位来表示 在C#里 字符串通常由string来声明,字符由char来声明,字节由byte来表示,位由bit来表示,具体分析见下面的测试代码分析: 完整测试代码: using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using Syst…
网上总是说Runable和Thread可以实现线程,这导致我对Thread和Runable有错误的理解,谁让当时不求甚解,让我一直以为实现Runable可以开启线程. 看过源码后进行区分这两者. 无论怎么样,线程都是通过Thread创建的. 其一:Runable只是一个接口,不会开启一个线程,依旧是运行在UI线程中. public interface Runnable { /** * Starts executing the active part of the class' code. Thi…
疑问:怎样获取开发者许可证 打开VS2012时,怎么在没有取得开发者许可证之前,屏蔽/跳过弹出的窗体“获取Windows8开发者许可证 你需要具有开发者许可证才能开发适用于......” 打开Blend for Visual Studio 2012时弹出的窗体“无法获取windows开发人员许可证.错误代码:800704C7.是否要重新尝试获取许可证?“ 解答: 在本地计算机上首次运行 Microsoft Visual Studio 2012 时,系统会提示你获取开发者许可证.请阅读许可条款,然…
今天闲的时候trace route了yahoo和sina的域名,yahoo的如下: 1 1 ms 1 ms <1 ms 172.21.127.1 2 3 ms <1 ms <1 ms 10.236.253.17 3 3 ms 3 ms 3 ms 10.236.253.46 4 12 ms 6 ms 5 ms 172.21.202.198 5 103 ms 100 ms …
一.浅拷贝 当我们需要将一个对象拷贝至另一个对象时,我们一般会这么实现 function shadowCopy(source,target){ var target=target||{}; for(var i in source) { target[i]=source[i]; } return target; } var a={name:'Lily',age:19}; var b=shadowCopy(a);//b={name:'Lily',age:19} 浅拷贝的问题是,如果父对象的属性等于数…
昨天CSAPP上的疑问的解答 今天整明白了. CSAPP英文版第2版,826页,或者中文版第2版546页,有这么一段.关于多级页表的. "But if we had a 32-bit address space, 4KB pages, and a 4-byte PTE[page table entry, 杨注], then we would need a 4MB page table resident in memory at all time..." 其中"32-bit a…
在RFC2741中这样定义: 4.3中有如下段落: A general architectural division of labor between master agent and subagent: master agent和subagent有这明确的分工: The master agent is MIB ignorant and SNMP omniscient, while the subagent is SNMP ignorant and MIB omniscient (for th…