Этот код C # должен работать:
public static string[] SplitByLength(string text, int length)
{
// According to your comments these checks aren't necessary, but
// I think they're good practice...
if (text == null)
{
throw new ArgumentNullException("text");
}
if (length <= 0)
{
throw new ArgumentOutOfRangeException("length");
}
if (text.Length % length != 0)
{
throw new ArgumentException
("Text length is not a multiple of the split length");
}
string[] ret = new string[text.Length / length];
for (int i = 0; i < ret.Length; i++)
{
ret[i] = text.Substring(i * length, length);
}
return ret;
}
Reflector преобразует это в VB как:
Public Shared Function SplitByLength(ByVal [text] As String, _
ByVal length As Integer) As String()
' Argument validation elided
Dim strArray As String() = New String(([text].Length \ length) - 1) {}
Dim i As Integer
For i = 0 To ret.Length - 1
strArray(i) = [text].Substring((i * length), length)
Next i
Return strArray
End Function
Возможно, это не идиоматический VB, поэтому яв том числе и C #.