помогите с конвертацией...
Код:
private static byte[] one( string str )
{
byte[] abRetVal = null;
if ( str.Length > 0 )
{
abRetVal = new byte[ str.Length + 1 ];
for ( int i = 0 ; i < str.Length ; i++ )
{
abRetVal[ i ] = Convert.ToByte( str[ i ] );
}
abRetVal[ str.Length ] = 0;
}
return abRetVal;
}
private static string two( byte[] array )
{
int col = 0;
string strRetVal = null;
if ( array.Length > 0 )
{
for ( int i = 0 ; i < array.Length ; i++ )
{
if ( array[ i ] == 0 )
{
break;
}
col++;
}
char[] CharArray = new char[ col ];
for ( int i = 0 ; i < col ; i++ )
{
CharArray[ i ] = System.Convert.ToChar( array[ i ] ) ;
}
strRetVal = new string( CharArray );
}
return strRetVal;
}