Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

array storage

Posted on 2007-03-26
2
Medium Priority
?
198 Views
Last Modified: 2012-05-05
I have a string like "60165F010430313037"

I have to store each 2 chars in an byte array or simply an array like

a[0] = 60
a[1] = 16
a[2] = 5F

...like that
0
Comment
Question by:Rahamathulla_J
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Expert Comment

by:WinterMuteUK
ID: 18792907
The simple route would be something like:

            string splitMe = "60165F010430313037";
            string[] a = new string[splitMe.Length / 2];
            int start = 0;
            for (int i = 0; i < splitMe.Length / 2; i++)
            {
                a[i] = splitMe.Substring(start, 2);
                start += 2;
            }

Not sure how you'd convert it to a byte array though.
0
 
LVL 25

Accepted Solution

by:
dstanley9 earned 1000 total points
ID: 18793072
string source = "60165F010430313037";
byte[] bytes = new byte[source.Length/2];
for(int i=0 ; i < source.Length/2 ; i++)
{
  string s = source.Substring(2*i,2);
  b[i] = byte.Parse(s,System.Globalization.NumberStyles.HexNumber);
}
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question