将代码从C#转换为Vb.net的一些方法 [英] Some Probem in converting code from c# to Vb.net
问题描述
我在C#中有1个项目,我将其转换为vb.net,但我在其中遇到了一些困难,这部分代码可以在C#中正常工作,但是如果我们将其转换为VB.net,则会出现错误,我给你们两个代码,请给我正确的代码....
C#
I have 1 project in c# i am converted it into vb.net but i got some difficulty in it some part of code which is properly worked in C# but if we convert into VB.net then it gives error i give you both codes if possible then give me the right code please....
C#
static string GetCoreSound(string str, ref int totalCoreSoundCharacter)
{
string soundmap = "अबसदइफगहईजकलमनओपकरसतउववज़यज";
string h_shift = GethShift(str,ref totalCoreSoundCharacter);
if (h_shift == null)
{
int position = ((str[0]) - 'a');
if (position < soundmap.Length && position >= 0)
{
return "" + soundmap[position];
}
totalCoreSoundCharacter=1;
return str;
}
else
{
return h_shift;
}
}
VB.net
VB.net
Private Shared Function GetCoreSound(ByVal str As String, ByRef totalCoreSoundCharacter As Integer) As String
Dim soundmap As String = "अबसदइफगहईजकलमनओपकरसतउववज़यज"
Dim h_shift As String = GethShift(str, totalCoreSoundCharacter)
If h_shift Is Nothing Then
Dim position As Integer = ((str(0)) - "a"c)
If position < soundmap.Length AndAlso position >= 0 Then
Return "" & soundmap(position)
End If
totalCoreSoundCharacter = 1
Return str
Else
Return h_shift
End If
End Function
******************************************************
代码粗体出现问题....
" Dim position As Integer = ((str(0)) - "a"c)"
这条线不起作用,所以请告诉我正确..
-
致以问候
Apeksha Deshpande
**************************************************
where the code is bold there is problem....
" Dim position As Integer = ((str(0)) - "a"c)"
this line is not working so please tell me proper..
--
With Regards
Apeksha Deshpande
推荐答案
使用以下内容更新问题行
update the problem line with below
Dim position As Integer = Convert.ToInt32(s(0)) - Convert.ToInt32("a"c)
希望对您有帮助
--hemant
Hope it will help
--hemant
这篇关于将代码从C#转换为Vb.net的一些方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!