求帮助,把以下的C#修改为VB.NET
高手们,代码不多,但本人不太懂C#的东西,请帮忙修改一下,感谢!
private static string ReplaceEx2(string original, string pattern, string replacement)
{
int count, position0, position1;
count = position0 = position1 = 0;
string upperString = original.ToUpper();
string upperPattern = pattern.ToUpper();
int inc = (original.Length/pattern.Length)*(replacement.Length-pattern.Length);
char [] chars = new char[original.Length + Math.Max(0, inc)];
while( (position1 = IndexOf2(upperString, upperPattern, position0)) != -1 )
{
for ( int i=position0 ; i < position1 ; ++i ) chars[count++] = original[i];
for ( int i=0 ; i < replacement.Length ; ++i ) chars[count++] = replacement[i];
position0 = position1+pattern.Length;
}
if ( position0 == 0 ) return original;
for ( int i=position0 ; i < original.Length ; ++i ) chars[count++] = original[i];
return new string(chars, 0, count);
}
private static int IndexOf2(string T, string P, int i)
{
int step = T.Length-P.Length;
for ( ; i <= step ; ++i )
{
for ( int j=0 ; j < P.Length ; ++j )
{
if ( T[i+j] != P[j] )
{
goto LOOP;
}
}
return i;
LOOP:;
}
return -1;
}
------解决方案--------------------给你一个一般的方法,在VS中贴上这些代码,编译,用ILSpy++打开,反编译,上面下拉选择VB.NET,完成。
------解决方案--------------------http://www.developerfusion.com/tools/convert/csharp-to-vb/
------解决方案--------------------
Private Shared Function ReplaceEx2(original As String, pattern As String, replacement As String) As String
Dim count As Integer, position0 As Integer, position1 As Integer
count = InlineAssignHelper(position0, InlineAssignHelper(position1, 0))
Dim upperString As Stri