Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7580101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:49:55+00:00 2026-05-30T17:49:55+00:00

I having some issues with converting a large byte[] array into a strongly typed

  • 0

I having some issues with converting a large byte[] array into a strongly typed array.

  1. I have an array which has been concatinated into one large byte[] array and stored in a table.
  2. I want to then read this byte[] array but convert it to a strongly typed array.

As I have stored the entire array as a byte[] array, can I not read that byte array and convert it to my strongly typed version? At the moment its returning null…

Is this possible in one hit?

Thanks in advance, Onam.

<code>
    #region Save
    public void Save<T>(T[] Array) where T : new()
    {
        List<byte[]> _ByteCollection = new List<byte[]>();
        byte[] _Bytes = null;
        int _Length = 0;
        int _Offset = 0;

        foreach (T _Item in Array)
        {
            _ByteCollection.Add(Serialise(_Item));
        }
        foreach (byte[] _Byte in _ByteCollection)
        {
            _Length += _Byte.Length;
        }

        _Bytes = new byte[_Length];

        foreach (byte[] b in _ByteCollection)
        {
            System.Buffer.BlockCopy(b, 0, _Bytes, _Offset, b.Length);
            _Offset += b.Length;
        }
        Customer[] c = BinaryDeserialize<Customer[]>(_Bytes);
    }
    #endregion

    #region BinaryDeserialize
    public static T BinaryDeserialize<T>(byte[] RawData)
    {
        T _DeserializedContent = default(T);

        BinaryFormatter _Formatter = new BinaryFormatter();
        try
        {
            using (MemoryStream _Stream = new MemoryStream())
            {
                _Stream.Write(RawData, 0, RawData.Length);
                _Stream.Seek(0, SeekOrigin.Begin);
                _DeserializedContent = (T)_Formatter.Deserialize(_Stream);
            }
        }
        catch (Exception ex)
        {
            _DeserializedContent = default(T);
        }

        return _DeserializedContent;
    }
    #endregion
</code>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:49:57+00:00Added an answer on May 30, 2026 at 5:49 pm

    I think the problem is that you are serializing each item to a list, then concatenating the bytes. When this is deserialised this just looks like the data for one customer plus some unexpected data (the other customers) at the end.

    I don’t know how your serialize method works but you can probably just change code:

        foreach (T _Item in Array)
        {
            _ByteCollection.Add(Serialise(_Item));
        }
    

    To:

    _ByteCollection.Add(Serialise(Array));
    

    And that should work, then you could probably simplify it a little.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been having some issues with LINQ-To-SQL around memory usage. I'm using it
We've been having some issues with a SharePoint instance in a test environment. Thankfully
We've been having some issues with our MySQL server intermittently. It keeps throwing out
I'm having some issues with the following code: var tmpArray = new Array(); for(var
I am having some issues with a small program I have made that edits
I have a website that seems to be having some issues with either the
Having some issues accessing my param tags from within actionscript. Essentially I have the
I am having some issues trying to create page navigation using php, I have
I've been having some issues with a pagination widget that I wrote in jQuery.
Having some issues getting my head around the differences between UTF-8, UTF-16, ASCII and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.