I need to remove byte where value is 0 from a byte array.
Please help..
this removing the first position,Code:byte[] newArray = oldArray.Where(b => b != 0xff).ToArray();
Printable View
I need to remove byte where value is 0 from a byte array.
Please help..
this removing the first position,Code:byte[] newArray = oldArray.Where(b => b != 0xff).ToArray();
If you want to remove elements where the value is equal to 0 then why are you telling it to remove elements where the value is not equal to 255?
The code you show filters the old array for all values that are not equal to 255 (0xff).
If you want to filter out 0's use b => b != 0.
Edit, oops bit slow (got carried away playing with lambda)
No, actually i don't know the meaning of that code, when i surfed in net for removing byte from byte array.. i got something like above.. so that i tried and copied here..
i used RemoveAll(Predicate<T> match), its working fine.
i have to learn linq its reducing much steps..
byte[] newArray = oldArray.Where(b => b != 0).ToArray();
its simple rather than using list.
thanks milk,