Ho dei problemi a tradurre questa funzione da VB a C#

codice VB:

Public Function setFormatDate(ByVal data As String)

If Len(data) = 8 Then
Return "20" & Right(data, 2) & "/" & Mid(data, 4, 2) & "/" & Left(data, 2)
ElseIf Len(data) = 10 Then
Return Right(data, 4) & "/" & Mid(data, 4, 2) & "/" & Left(data, 2)
Else
Throw New Exception("La data " & data & " da formattare ha un formato non riconosciuto")
End If

End Function


per ora ho fatto:

protected string setFormatDate(string data)
{
try
{
if (lenght(data)==8)
{
return "20" + Right(data, 2) + "/" + Mid(data, 4, 2) + "/" + Left(data, 2);
}

else if (lenght(data)==10)
{
return Right(data, 4) + "/" + Mid(data, 4, 2) + "/" + Left(data, 2);
}
}

catch (Exception exc)
{
string debug = "La data " & data & " da formattare ha un formato non riconosciuto " + exc.Message;
return null;
}
}


ma i comandi Mid, left, right, lenght non vanno bene...

qualcuno mi può aiutare??

Grazie