how do I interprate a sting of 1 or 0 in a clever way

T

tony

Hello!

I have 10 string fields which are elements or gas or someting else and some
symbol behind if less then or greater then se below. In the database there
is a string telling which field should be used by setting 1 or 0 in the
actual position. So for example field in position 5 is field Si<.
If only this field Si< should be used then the string in the database has
this look 00000100000
If all fields should be used then the string in the database look like
11111111011.
As you can see position 8 is not used and is always 0.

Now to my question is it anybody that have some clever algoritm to load an
array with the elements that
has setting 1.

index
0. C<
1. N<
2. N>
3. T<
4. T>
5. Si<
6. O2>
7. N2>
8.
9. Ar>
10. Time

Many thanks

//Tony
 
T

the.duckman

Im sure you are cappable of doing this on your own if you work at it.
To my experince new programmers lack more in confidence than skills.

big hint...

string flags = "110011001";
for(int n = 0; n<flags.Lenght; n++)
if(flags[n] == '1')
{
//add to array
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top