VB(?)代码到C#的转换 [英] Conversion of VB(?) code to C#

查看:102
本文介绍了VB(?)代码到C#的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我们公司的一位前员工留下了以下(VB?)代码:

Hi,
An ex-worker of our company left the following (VB?) code:

function AuthenticateUser(UserName, Password, Domain)
dim strUser
' assume failure
AuthenticateUser = false
strUser = UserName
strPassword = Password
strQuery = "SELECT cn FROM 'LDAP://" & Domain & "' WHERE objectClass='*' "
set oConn = server.CreateObject("ADODB.Connection")
oConn.Provider = "ADsDSOOBJECT"
oConn.Properties("User ID") = strUser
oConn.Properties("Password") = strPassword
oConn.Properties("Encrypt Password") = true
oConn.open "DS Query", strUser, strPassword
set cmd = server.CreateObject("ADODB.Command")
set cmd.ActiveConnection = oConn
cmd.CommandText = strQuery
on error resume next
set oRS = cmd.Execute
if oRS.bof or oRS.eof then
AuthenticateUser = false
else
AuthenticateUser = true
end if
set oRS = nothing
set oConn = nothing
end function


由于升级功能,此代码需要转换为C#.
有人可以帮我吗?


Due to upgrade functions, this code needs to be converted to C#.
Can anyone help me with that?
Thanks.

推荐答案

将其编译为DLL,然后使用Reflector将其反汇编为C#.

哦,这看起来像VB6.在这种情况下,反射器"的想法将行不通.查看System.Data.SqlClient.
Compile it as a DLL, then use Reflector to disassemble it into C#.

Oh, this looks like VB6. In that case, the Reflector idea will not work. Look into System.Data.SqlClient.


这里是一个链接,可以在VB.NET和C#中执行所需的操作.向下滚动到页面的大约三分之一,C#代码在VB代码之后.它也有很好的注释,因此您可以弄清楚发生了什么.

http://forums.asp.net/t/1250726.aspx [
Here''s a link that does what you want in VB.NET and C#. Scroll down to about a third of the way down the page and the C# code comes after the VB code. It''s also well annotated so you can figure out what''s going on.

http://forums.asp.net/t/1250726.aspx[^]

Good luck!


或者您可以在线将其转换为 http://converter.telerik.com/ [^ ]
Or you can go online and convert it here http://converter.telerik.com/[^]


这篇关于VB(?)代码到C#的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆