[英]Help converting some classic asp code to c# (.net 3.5)
I have this block of code in a .asp file that I am struggling to convert to c#... can anyone help me? 我在努力转换为C#的.asp文件中有这段代码,...有人可以帮助我吗?
Function EncodeCPT(ByVal sPinCode, ByVal iOfferCode, ByVal sShortKey, ByVal sLongKey)
Dim vob(2), encodeModulo(256), decodeX, ocode
decodeX = " abcdefghijklmnopqrstuvwxyz0123456789!$%()*+,-.@;<=>?[]^_{|}~"
if len(iOfferCode) = 5 then
ocode = iOfferCode Mod 10000
else
ocode = iOfferCode
end if
vob(1) = ocode Mod 100
vob(0) = Int((ocode-vob(1)) / 100)
For i = 1 To 256
encodeModulo(i) = 0
Next
For i = 0 To 60
encodeModulo(asc(mid(decodeX, i + 1, 1))) = i
Next
'append offer code to key
sPinCode = lcase(sPinCode) & iOfferCode
If Len(sPinCode) < 20 Then
sPinCode = Left(sPinCode & " couponsincproduction", 20)
End If
'encode
Dim i, q, j, k, sCPT, s1, s2, s3
i = 0
q = 0
j = Len(sPinCode)
k = Len(sShortKey)
sCPT = ""
For i = 1 To j
s1 = encodeModulo(asc( mid(sPinCode, i, 1)) )
s2 = 2 * encodeModulo( asc( mid(sShortKey, 1 + ((i - 1) Mod k), 1) ) )
s3 = vob(i Mod 2)
q = (q + s1 + s2 + s3) Mod 61
sCPT = sCPT & mid(sLongKey, q + 1, 1)
Next
EncodeCPT = sCPT
End Function
What you have here seems to be pretty standard VBScript code. 您在这里拥有的似乎是非常标准的VBScript代码。
Perhaps you could look at some C# tutorial to get the basics or maybe go for VB.NET instead of C#. 也许您可以看一些C#教程以获取基础知识,或者可以选择VB.NET而不是C#。
The syntax is pretty much the same as VBScript, but remember, the .NET framework is object oriented so some feature or functions are not implemented the same way. 语法与VBScript几乎相同,但是请记住,.NET框架是面向对象的,因此某些功能部件不是以相同的方式实现的。
For example, if you want to get the length of a string, you would be using myString.Length instead of Len(myString). 例如,如果要获取字符串的长度,则将使用myString.Length而不是Len(myString)。
Here are a few C# and VB.NET tutorials for you to look at. 这里有一些C#和VB.NET教程供您查看。
http://www.csharp-station.com/Tutorial.aspx http://www.csharp-station.com/Tutorial.aspx
http://www.csharpkey.com/csharp/Lesson01.htm http://www.csharpkey.com/csharp/Lesson01.htm
http://www.programmersheaven.com/2/VB-NET-School http://www.programmersheaven.com/2/VB-NET-School
http://www.homeandlearn.co.uk/net/vbnet.html http://www.homeandlearn.co.uk/net/vbnet.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.