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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:39:14+00:00 2026-05-27T11:39:14+00:00

I am trying to do 2 different sorting algorithms on 2 exactly similar arrays

  • 0

I am trying to do 2 different sorting algorithms on 2 exactly similar arrays (numbers and numbers2) that are generated through the Random class. I declare my 2 arrays and fill them with Random.NextBytes.

After that I do my first algorithm on numbers and then my second sorts on numbers2.

But I notice that numbers2 just seems to be a pointer to numbers because by the time I want to sort numbers2 it is already sorted.

How do I fill numbers2 with exactly the same numbers as numbers? Do I need to do it by hand with a for loop? Thank you!

class FillArray
   {

    public byte[] numbers;
    public byte[] numbers2;

        //instantiate MS Random object
        Random Generator = new Random();


        //Constructor which takes array size
        public FillArray(int amountx)
        {
          numbers = new byte[amountx]
          Generator.NextBytes(numbers);
          numbers2 = new byte[amountx];
          numbers2 = numbers;
          amount = amountx;
        }
  • 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-27T11:39:15+00:00Added an answer on May 27, 2026 at 11:39 am

    Arrays are reference types, so if you want to clone the array you’ll need to copy it via Array.Copy.

    int[] first = new int[] { 1, 2, 3, 4, 5 };
    int[] second = new int[first.Length];
    Array.Copy( first, second, first.Length );
    
    first[0] = 10;
    
    // prints 10
    Console.WriteLine( first[0] );
    
    // prints 1
    Console.WriteLine( second[0] );
    

    You can also use Array.CopyTo. If you don’t have a pre-existing array you can use the Clone() method as well to create a new one with shallow copies of all elements.

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

Sidebar

Related Questions

I'm trying to create a program which will visualize different sorting algorithms by drawing
I was looking into different sorting algorithms, and trying to think how to port
I am trying a different kind of sorting in Oracle.Its like I have three
While playing with different sort algorithms I was surprised that Groovy closures were performing
I was messing around with Python trying to practice my sorting algorithms and found
I'm trying different data structures for implementing Prim's algorithm. So I made a class
For a long time I've been trying different languages to find the feature-set I
Third try at fixing this tonight - trying a different approach than before now.
Im trying to apply different background color to even and odd items in a
I am trying to add different styles within a textarea eg bold, different colors

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.