Tostring ("x2 ")

Source: Internet
Author: User

/// <Summary>
/// Convert byte type to string
/// </Summary>
/// <Param name = "arrinput"> byte array </param>
/// <Returns> Target string </returns>
Private string bytearraytostring (byte [] arrinput)
{
Int I;
Stringbuilder soutput = new stringbuilder (arrinput. Length );
For (I = 0; I <arrinput. length; I ++)
{
Soutput. append (arrinput [I]. tostring ("X2 "));
}
// Convert the Instance value to system. String
Return soutput. tostring ();
}

 

/// <Summary>
/// Unpackage the received data (unpack the received byte array as a unicode string)
/// </Summary>
/// <Param name = "recbytes"> byte array </param>
/// <Returns> Unicode-encoded string </returns>
Public String dispackage (byte [] recbytes)
{
String temp = "";
Foreach (byte B in recbytes)
Temp + = B. tostring ("X2") + ""; // tostring ("X2") is the string format controller in C #
Return temp;
}

========================================================== ====================

Tostring ("X2") is the string format controller in C #

X is hexadecimal
2. It indicates that each request is a double digit.

For example, 0x0a. If there is no 2, only 0xa is output.
Assume that there are two numbers 10 and 26. Normally, the hexadecimal format displays 0xa and 0x1a, which looks untidy. To look good, you can specify "X2". The displayed result is: 0x0a, 0x1a.
Reference: http://topic.csdn.net/t/20050709/17/4133902.html

From: http://www.cnblogs.com/kuang906/articles/2301361.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.