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

  • SEARCH
  • Home
  • 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 8346649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:05:17+00:00 2026-06-09T07:05:17+00:00

I am trying to use Buffer.BlockCopy to copy a portion of an array (data.item)

  • 0

I am trying to use Buffer.BlockCopy to copy a portion of an array (data.item) into another. I get a compiler error about invalid stuff (see below) if I try one thing, or a runtime error if I use a cast. But it works fine if I just assign it: row[item.AspecName] = “random chars”. What am I wrong doing?

namespace ObjectListViewFramework
{
    public partial class ObjectListviewForm : Form
    {
        public DataTable ListRows { get; private set; }
  }

 }

    public void AddRows2(DLL_conduit data)
    {
        int columnIndex;
        int bufferIndex = 0;
        for (int rowIndex = 0; rowIndex < data.rowCount; rowIndex++)
        {
            DataRow row = ListRows.NewRow();
            columnIndex = 0;
            foreach (var item in objectListView1.AllColumns)
            {
                // this works dandy
               row[item.AspectName] = "random chars";

                // compiler error: the best overloaded method match has some invalid args
                 Buffer.BlockCopy(data.item, bufferIndex, row[item.AspectName], columnIndex * 256, 256);

                 // runtime error: invalid cast 
                 Buffer.BlockCopy(data.item, bufferIndex, (char[])row[item.AspectName], columnIndex * 256, 256);      

                ++columnIndex;
                bufferIndex += 256;
            }
            ListRows.Rows.Add(row);
        }
        objectListView1.AddObjects(ListRows.DefaultView);
    }
  • 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-06-09T07:05:18+00:00Added an answer on June 9, 2026 at 7:05 am

    Initially your row doesn’t have any associated data.

    Buffer.BlockCopy doesn’t create an array to copy into. You have to pass it an existing array, and you don’t have one.

    Your working code uses an indexed setter. Your non-working code uses the indexed getter to retrieve the object currently in the DataRow.

    Uses of Buffer.BlockCopy are few and far between.

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

Sidebar

Related Questions

I get the following error when trying to use Response.Redirect in one of my
I am trying to learn to use buffer overflow attack in Ubuntu. Unfortunately, I
I am trying to use logging's memory handler to buffer log messages to my
i have a char buffer[100] and i'm trying to use gdb to read the
I was trying to use a struct to parse socket data when implement a
I am getting this the following error when I am trying to use OpenGL
I'm trying to use GMFBridge to switch between multiple stream buffer graphs and I
I am trying to use libjpeg to save a screenshot from an opengl buffer.
I am trying to use 'GetModuleFileNameA' but I keep getting the error 'c4430: missing
So, I'm trying to use ADO.NET to stream a file data stored in an

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.