谁能把下面的VB代码翻译为C#
Private Function GetKeyByteArray(ByVal sPassword As String) As Byte()
dim byteTemp(7) As Byte
sPassword=sPassword.PadRight(8);
Dim iCharIndex As Integer
For iCharIndex =o To 7
byteTemp(iCharIndex)=Asc(Mid$(sPassword,iCharIndex+1,1))
Next
Return byteTemp
End Function
在C#中
textBox.PasswordChar就可以完成任务!
private void InitializeMyControl()
{
// Set to no text.
textBox1.Text = "";
// The password character is an asterisk.
textBox1.PasswordChar = '*';
// The control will allow no more than 14 characters.
textBox1.MaxLength = 14;
}
private Byte[] GetKeyByteArray(String sPassword)
{
Byte byteTemp[8];
sPassword = sPassworkd.PadRight(8);
int iCharIndex;
for(iCharIndex = 0; iCharIndex < 8; iCharIndex++)
{
byteTemp[iCharIndex) = Convert.ToInt32(sPassword.SubString(iCharIndex, 1));
}
return byteTemp;
}