C# String to SByte[] to String

        private static string SByteArrayToString(sbyte[] sbytes)
        {
            //Convert sbyte[] to byte[]
            byte[] byteData = Array.ConvertAll(sbytes, (a) => (byte)a);
            return Encoding.ASCII.GetString(byteData);
        }

        private static sbyte[] StringToSByte(string value)
        {
            // convert string to byte array
            byte[] bytes = Encoding.ASCII.GetBytes(value);

            // convert byte array to sbyte array
            sbyte[] sbytes = new sbyte[bytes.Length];
            for (int i = 0; i < bytes.Length; i++)
                sbytes[i] = (sbyte)bytes[i];

            return sbytes;
        }
Advertisements
This entry was posted in .NET, BizTalk Server. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s