Ty for the answer, i have nice options here! [?]

2010/7/27 Theraot <[email protected]>

> //watashi no falo e vostro idiom. :P C# gomen nasei?
>
> I know peoples, that this may be one of those left with no answer, we
> like to enforce english, isn't it?
>
>        static byte[] convert (byte?[] array) //converts one to one,
> low memory use and fast to write
>        {
>            const byte nullvalue = 0;
>            return Array.ConvertAll<byte?, byte>
>                (
>                    array
>                    ,
>                    input =>
>                    {
>                        if (input.HasValue)
>                        {
>                            return input.Value;
>                        }
>                        else
>                        {
>                            return nullvalue;
>                        }
>                    }
>                );
>        }
>
>        static byte[] convert (byte?[] array) //A bit more versatile
>        {
>            const byte nullvalue = 0;
>            int length = array.Length;
>            List<byte> result = new List<byte>();
>            for (int i = 0; i < length; i++)
>            {
>                byte? input = array[i];
>                if (input.HasValue)
>                {
>                    result.Add(input.Value);
>                }
>                else
>                {
>                    result.Add(nullvalue);
>                    //use "continue" instead to skip the nulls
>                }
>            }
>            return result.ToArray();
>        }
>
>        static byte[] convert (byte?[] array) //Concurrent, no
> warranty on the order, fater with multiple cores
>        {
>            const byte nullvalue = 0;
>            int length = array.Length;
>            var result = new
> System.Collections.Concurrent.ConcurrentQueue<byte>();
>            System.Threading.Tasks.Parallel.For
>                (
>                    0,
>                    length,
>                    i =>
>                    {
>                        byte? input = array[i];
>                        if (input.HasValue)
>                        {
>                            result.Enqueue(input.Value);
>                        }
>                        else //skip this else to skip the nulls
>                        {
>                            result.Enqueue(nullvalue);
>                        }
>                    }
>                );
>            return result.ToArray();
>        }
>
> Let's try to make something useful of this thread, now that I've made
> the above gift, that has the risk of being just copy->paste and never
> understood....
> Hesre the situation, any body can write a concurrent solutuon that
> warranties the order and allows to skip the nulls? and what the
> solution of those that has the less memory usage?
>
> On 26 jul, 07:10, Bernardo Rosmaninho <[email protected]>
> wrote:
> > Bom dia galera,
> >    Alguém já teve que gravar em um campo BLOB not null e tenho que
> converter
> > um array de bytes Nulable em um array de bytes.
> >    Podem me dar uma ajuda?
> > []'s
> >
> > --
> > Bernardo Rosmaninho
>



-- 
Bernardo Rosmaninho

<<330.gif>>

Reply via email to