Programming, website development forum Get latest updates by RSS Follow TechnicalTalk on Twitter Follow TechnicalTalk on Facebook 
HomeSearchRecent PostsLoginRegisterContact Us

Username  
Password    
  Forgot your password?  

Pages: [1]   Go Down
 
  Email this topic  |  Print
0 Members and 1 Guest are viewing this topic.

Convert hexa-decimal octets to Text -C#.net

 
webmaster forum
shefeekj  Offline
For Technical Information
Activity
0%
 
New Coder
Posts: 26
Topics: 11
WWW
April 14, 2009, 06:33:26 AM

Here is the C#.net function to convert hexadecimal octets to TEXT  .The code is not optimized..Please contact me if you need any help……

Code:
public void CovertFromHex(string[] hexValue,int length)
{
            int count = 1,pos=0;
            string[] hexInput = new string[hexValue.Length];
            string[] splitstring = new string[8];
            string[] bin = new string[100];
            string concat = string.Empty;
            string temp=string.Empty;
         

                for (int i = 0; i <= length; i++)
                {

                    string extract = hexValue[i].ToString();

                    if(extract!=string.Empty)
                    {
                    string[] x = new string[count];
                    for (int k = 0; k < extract.Length; k++)
                    {
                        if (k == length)
                        {
                        }
                        else if (k >= count)
                        {
                            concat = “” + concat + extract.Substring(k, 1) + “”;
                         }
                        else
                        {
                         
                            x[k] = extract.Substring(k, 1);
                        }
                    }
                    bin[pos] = “” + concat + temp + “”;
                    temp = string.Empty;
                    concat = string.Empty;
                    count = count + 1;

                       
                    for (int j = 0; j < x.Length; j++)
                    {
                        temp = “” + temp + x[j].ToString() + “”;
                    }
                    pos++;
                    if (count == 8  )
                    {
                        count = 1;
                        bin[pos] = temp;
                        temp = string.Empty;
                        pos++;

                    }
                        }
                }
                bin[pos-1] = “” + temp + bin[pos-1].ToString() +”";

}
« Last Edit: April 14, 2009, 06:39:58 AM by polas »

http://www.shefeekj.com
 
webmaster forum
polas  Offline
Activity
33.33%
 
Code Guru
Gender: Male
Posts: 1399
Topics: 85
WWW
April 14, 2009, 06:55:54 AM

Thats a lot of code for something so simple... nice post, but is there a way to do it without all that code (like in the converting one number base to another post you did)?

Mesham Type Oriented Parallel Programming Language, Free online technical support
 
  Email this topic  |  Print
Pages: [1]   Go Up
 
Jump to:  



Powered by SMF 1.1.15 | SMF © 2011, Simple Machines


Google visited last this page February 03, 2012, 03:04:54 PM