【发布时间】:2012-07-18 11:22:44
【问题描述】:
我需要将下面的函数转换为VB.NET,但我不知道如何处理该语句
res = (uint)((h * 0x21) + c);
功能齐全:
private static uint convert(string input)
{
uint res = 0;
foreach (int c in input)
res = (uint)((res * 0x21) + c);
return res;
}
我创建了以下内容,但出现溢出错误:
Private Shared Function convert(ByVal input As String) As UInteger
Dim res As UInteger = 0
For Each c In input
res = CUInt((res * &H21) + Asc(c)) ' also tried AscW
Next
Return res
End Function
我错过了什么?谁能解释一下细节?
【问题讨论】:
-
哪些输入失败了?你确定你没有传递一个对于 UInt32 来说太大的输入吗?
-
我认为字符串导致它超出
uint限制
标签: c# vb.net code-conversion