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 7594773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:30:16+00:00 2026-05-30T21:30:16+00:00

I have a problem filling an array argument without the ref keyword. For this

  • 0

I have a problem filling an array argument without the ref keyword.

For this signature:

int ReceiveData(ref byte[] data)

this works:

byte[] dataParameter = new byte[8];
byte[] testData = new byte[] { 1, 2, 3, 4 };
this.mockObject.Stub(t => t.ReceiveData(ref dataParameter)).OutRef(testData).Return(4);

After calling “ReceiveData” the “data” argument has the value { 1, 2, 3, 4 }.
What should I do to fill the data argument for this signature:

int ReceiveData(byte[] data)

OutRef() doesn’t work for this. Any idea?
Thanks…

  • 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-30T21:30:17+00:00Added an answer on May 30, 2026 at 9:30 pm

    I was just having a similar problem and found my solution with the ‘Callback’ method. In my case, the input buffer argument is not declared ‘ref’, so might not be quite right for you, but I think it should work.

    For example;

    mockObject.Expect(x => x.ReceiveData(Arg<byte[]>.Is.NotNull)).Callback((byte[] buffer) =>
    {
       Array.Copy(outBytes, 0, buffer, 0, outBytes.Length);
       return true;
    }).Return(10); // return some number of bytes received, and set the bytes in the callback 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with filling a Map in Java, I think this is simple,
I have this really random problem with is bugging me. It works at the
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem when I try insert some data to Informix TEXT column via
I'm kind of stuck with this problem. I have a UIImageView animation with 37
I´m having a problem with my Android Project. I have a screen filling custom
I have encountered a somewhat baffling problem with the simple task of filling an
I have a binary data which I am reading into an array of long
Hi i'm a objC noob. I have a problem filling an NSMutableArray with objects.
I have a problem with implementation of flood filling. The task is to ask

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.