VB.NET 如何计算方法的长度?我怎样才能在 C# 中做到这一点?
这是我的VB.NET代码:
Private Function ZeroPad(ByRef pNumber As Integer, ByRef pLength As Integer) As String
Dim Padding As Object
If IsNumeric(pNumber) And IsNumeric(pLength) Then
Padding = New String("0", pLength)
ZeroPad = Padding & CStr(pNumber)
ZeroPad = Right(ZeroPad, pLength)
Else
ZeroPad = CStr(pNumber)
End If
End Function
我转换成C#如下:
private string ZeroPad(ref int pNumber, ref int pLength) {
object Padding;
if ((IsNumeric(pNumber) && IsNumeric(pLength))) {
Padding = new string("0", pLength);
return (Padding + pNumber.ToString());
ZeroPad = ZeroPad.Substring((ZeroPad.Length - pLength));
// In the above line, how can I take the length of a method in C#?
}
else {
return pNumber.ToString();
}
}