易截截图软件、单文件、免安装、纯绿色、仅160KB

c#与最牛vb算法比拼 by Error


 
文章来源: http://www.zoesan.com By Error 302777528转载请注明出处
以上vb用到指针技术查找字符串与c#一般的.indexof()查找相比较,明显看出谁快谁慢。
VB:
Option Explicit
'指针方法操作字符串
'Copy一个字符串到缓存中
Public Declare Function GetTickCount Lib "kernel32" () As Long
Public Declare Function lstrcpy Lib "Kernel32.dll" Alias "lstrcpyW" (lpszString1 As Any, lpszString2 As Any) As Long
'通过指针获取字符串的长度
Public Declare Function lstrlen Lib "Kernel32.dll" Alias "lstrlenW" (ByVal lpszString As Long) As Long
Public Function FindTextInStr(ByVal OriStr As String, ByVal strText As String) As Long
Dim Buff() As Byte   '声明一个Byte数组
Dim Pointer As Long  '声明一个变量,用于存储指针
Pointer = StrPtr("Love")
ReDim Buff(0 To lstrlen(Pointer) * 2 - 1) As Byte  '分配缓存大小,由于得到的是Unicode,所以乘以2
lstrcpy Buff(0), ByVal Pointer   '复制到缓存Buff中
' Me.Caption = InStr(1, Buff, StrConv("o", vbfromUnicode))
FindTextInStr = InStr(OriStr, StrConv(strText, vbfromUnicode)) '查找子字符串位置
' Debug.Print Buff    '显示到text1中
End Function
Private Sub Command1_Click()
  Dim sTime As Long
  sTime = GetTickCount
  For i = 1 To 10000
  Call comPareTime
  
  Next
  sTime = GetTickCount - sTime
  Label1.Caption = "查找10000次粤ICP备05004654号花费" & sTime & "ms"
End Sub
Sub comPareTime()
   Dim i1 As Long
i1 = FindTextInStr(RichTextBox1.Text, "粤")
End Sub
'''''''''''''''''''''''''''''''''''''''''''
C#代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Configuration;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebContro


相关文档:

asp.net(c#)数据类型格式转换大全

1、DateTime   数字型 
       System.DateTime currentTime=new System.DateTime(); 
  1.1 取当前年月日时分秒 
       currentTime=System.DateTime.Now; 
  1.2 取当前年 
   &nb ......

C#生成XML文件的 函数

protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
         &nbs ......

C#连接MySql数据库方法 宇兰

1、用MySQLDriverCS连接MySQL数据库
先下载和安装MySQLDriverCS,地址:http://sourceforge.net/projects/mysqldrivercs/在安装文件夹下面找到MySQLDriver.dll,然后将MySQLDriver.dll添加引用到项目中注:我下载的是版本是 MySQLDriverCS-n-EasyQueryTools-4.0.1-DotNet2.0.exe using System;using System.Collectio ......

GDI+中发生一般性错误(asp.net(C#))

最近做保存远程图片时候,就在保存的时候总是出这个错误,网上google了一圈,都是再说权限问题,问题我是用U盘,哪里有什么权限问题。
最后无意中发现了问题所在
保存的时候不能用相对路径,一定要用server.mappath()处理一下保存的路径。。。唉! ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号