Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading List<Byte> from specific byte

Tags:

c#

.net

I have a List<Byte> with 10 values (4,6,9,25,64,31,54,15,98,33) and want to get a Byte<List> starting at a specific value/byte for example the value 54 (newbytelist: 54,15,98,33)

List<Byte> values;
List<Byte> newbytelist;

foreach (byte item in values.Skip("from value 54"))
{
    newbytelist.Add(item);
}

How can I do that?

like image 445
Struct Avatar asked Mar 21 '26 18:03

Struct


1 Answers

You are looking for SkipWhile method:

values.SkipWhile(x => x != 54);

An alternative using Skip would be:

values.Skip(values.IndexOf(54))
like image 81
Selman Genç Avatar answered Mar 23 '26 09:03

Selman Genç



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!