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
相关文档:
1、DateTime 数字型
System.DateTime currentTime=new System.DateTime();
1.1 取当前年月日时分秒
currentTime=System.DateTime.Now;
1.2 取当前年
&nb ......
protected void Page_Load(object sender, EventArgs e)
{
try
{
&nbs ......
-----------------------------.cs类文件中
当前项目的物理路径嘛:
strPath = this.Server.MapPath(Request.PhysicalApplicationPath);
你要说明什么“类文件”。任何PAGE、CONTROL代码也是在类 ......
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 ......
转载自:http://www.cnblogs.com/jdmei520/archive/2009/06/17/1505053.html
Webservice技术的出现将各种开发技术和语言完全的融合了,下面就这种融合在C#和delphi之间的交互做一次全面的体现
1.使用C#创建一个Webservice服务。
使用vs2005的模板创建C#的webservice非常容易。原文件如下:
[WebService(Namespace  ......