Click here to Skip to main content
15,917,005 members
Home / Discussions / C#
   

C#

 
GeneralRe: .NET Remoting, Client side reference server side? then how distribute? Pin
Heath Stewart26-Jun-04 13:53
protectorHeath Stewart26-Jun-04 13:53 
GeneralRe: .NET Remoting, Client side reference server side? then how distribute? Pin
Xiangyang Liu 刘向阳27-Jun-04 0:28
Xiangyang Liu 刘向阳27-Jun-04 0:28 
AnswerRe: .NET Remoting, Client side reference server side? then how distribute? Pin
Allen Anderson24-Jun-04 17:10
Allen Anderson24-Jun-04 17:10 
GeneralRe: .NET Remoting, Client side reference server side? then how distribute? Pin
fayth24-Jun-04 20:19
fayth24-Jun-04 20:19 
GeneralRe: .NET Remoting, Client side reference server side? then how distribute? Pin
Xiangyang Liu 刘向阳25-Jun-04 15:47
Xiangyang Liu 刘向阳25-Jun-04 15:47 
GeneralToolboxBitmap Icon Pin
The_Soul_Of_Rock24-Jun-04 14:48
The_Soul_Of_Rock24-Jun-04 14:48 
GeneralRe: ToolboxBitmap Icon Pin
Heath Stewart25-Jun-04 3:57
protectorHeath Stewart25-Jun-04 3:57 
GeneralConverting byte[] to Hex String; Pin
Bo Hunter24-Jun-04 12:27
Bo Hunter24-Jun-04 12:27 
I know that this is possible.

internal static string ByteArrayToHexString( byte[] buf )
{
	StringBuilder sb = new StringBuilder( buf.Length );
	for ( int i = 0; i != buf.Length; ++i )
	{
		sb.Append( buf[i].ToString( "X2" ) );
	}
	return ( sb.ToString() );
}


But I found this code in the BCL and was just trying to
make it work. The trouble I am having is in the lowwer
while loop. From what I can see is it is supposed to index
into the s_acharval array that contains the valid hex
digits. But I have had no luck in figuring it out.

internal unsafe static string ByteArrayToHexString( byte[] buf, int iLen )
{
	char[] chs1 = s_acharval;
	if ( chs1 == null )
	{
		chs1 = new char[16];
		int i = (int)chs1.Length;
		while ( --i >= 0 )
		{
			if ( i < 10 )
			{
				chs1[i] = (char)( 48 + i );
			}
			else
			{
				chs1[i] = (char)( 65 + ( i - 10 ) );
			}
		}
		s_acharval = chs1;
	}
	if ( buf == null )
	{
		return null;
	}
	if ( iLen == 0 )
	{
		iLen = (int)buf.Length;
	}
	char[] chs2 = new char[(uint)(iLen * 2)];
	fixed ( char* ch1 = &chs2[0])
	{
		fixed ( char* ch2 = &chs1[0])
		{
			fixed ( byte* b1 = &buf[0] )
			{
				char* ch3 = ch1;
				byte* b2 = b1;
				while ( --iLen >= 0 )
				{
					*ch3++ = *( ch2 + ( 2 * (( *b2 & 240 ) >> 4  )));
					*ch3++ = *( ch2 + ( 2 * ( *b2 & 15 )));
					b2++;
				}
			}
		}
	}

	return new String( chs2 );
}


Any help would be greatly appreciated.

Thank You
Bo Hunter
GeneralRe: Converting byte[] to Hex String; Pin
Heath Stewart24-Jun-04 12:42
protectorHeath Stewart24-Jun-04 12:42 
GeneralRe: Converting byte[] to Hex String; Pin
Bo Hunter24-Jun-04 14:24
Bo Hunter24-Jun-04 14:24 
GeneralRe: Converting byte[] to Hex String; Pin
Heath Stewart25-Jun-04 3:33
protectorHeath Stewart25-Jun-04 3:33 
GeneralRe: Converting byte[] to Hex String; Pin
Bo Hunter25-Jun-04 13:05
Bo Hunter25-Jun-04 13:05 
GeneralRe: Converting byte[] to Hex String; Pin
Karl 200027-Jun-04 10:16
Karl 200027-Jun-04 10:16 
GeneralRe: Converting byte[] to Hex String; Pin
Heath Stewart27-Jun-04 17:37
protectorHeath Stewart27-Jun-04 17:37 
GeneralRe: Converting byte[] to Hex String; Pin
Karl 200027-Jun-04 10:08
Karl 200027-Jun-04 10:08 
GeneralClearing Panel from Event Handler Pin
RobertVG24-Jun-04 11:21
RobertVG24-Jun-04 11:21 
GeneralRe: Clearing Panel from Event Handler Pin
Heath Stewart24-Jun-04 12:25
protectorHeath Stewart24-Jun-04 12:25 
GeneralRe: Clearing Panel from Event Handler Pin
RobertVG24-Jun-04 13:55
RobertVG24-Jun-04 13:55 
GeneralRe: Clearing Panel from Event Handler Pin
RobertVG24-Jun-04 13:56
RobertVG24-Jun-04 13:56 
GeneralRe: Clearing Panel from Event Handler Pin
RobertVG24-Jun-04 14:11
RobertVG24-Jun-04 14:11 
GeneralConcurrency Pin
IamADotNetGuy24-Jun-04 10:01
IamADotNetGuy24-Jun-04 10:01 
GeneralRe: Concurrency Pin
Dave Kreskowiak24-Jun-04 10:17
mveDave Kreskowiak24-Jun-04 10:17 
GeneralRe: Concurrency Pin
Xiangyang Liu 刘向阳24-Jun-04 17:13
Xiangyang Liu 刘向阳24-Jun-04 17:13 
GeneralDetaching event handlers Pin
Flack24-Jun-04 9:57
Flack24-Jun-04 9:57 
GeneralRe: Detaching event handlers Pin
Heath Stewart24-Jun-04 10:27
protectorHeath Stewart24-Jun-04 10:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.