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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:36:38+00:00 2026-06-10T13:36:38+00:00

there’s two methods i was looking at @stackOverFlow , i guess there might be

  • 0

there’s two methods i was looking at @stackOverFlow , i guess there might be even more of them
somewhere else , my qusetion is what is the best performance wise

and second question , i have this code that simply takes a couple of byte[]

     bool ArraysEqual(byte[] a1, byte[] a2)
     {
         if (a1 == a2)
             return true;
          if (a1 == null || a2 == null)
             return false;
          if (a1.Length != a2.Length)
             return false;
          for (int i = 0; i < a1.Length; i++)
         {
             if (a1[i] != a2[i])
                 return false;
         }
         return true;
     } 

and i couldn’t implement this one , not kowing the workaroud iguess i’ve used the wrong syntax
so if i have a helper method to read a byet[] file

    public byte[] readByteArr(string FilePath)
    {
       return File.ReadAllBytes(FilePath);

    } 

i could make it simply via 



void CompareIt(){

byte[] src = readByteArr(S.bar);
byte[] dest = readByteArr(D.bar);
if(ArraysEqual(src, dest))
DoSomthing
}

how do i make CompareIt(), with sets of parameters requierd in this Second code i allso try to implement, just to check which performs beeter

    bool ArraysEqual<T>(T[] a1, T[] a2)
    {
     if (ReferenceEquals(a1,a2))
         return true;
      if (a1 == null || a2 == null)
         return false;
      if (a1.Length != a2.Length)
         return false;
      EqualityComparer<T> comparer = EqualityComparer<T>.Default;
     for (int i = 0; i < a1.Length; i++)
     {
         if (!comparer.Equals(a1[i], a2[i]))
            return false;
     }
     return true;
 } 

what is the right syntax to implement this last one, and if there’s a quicker way to compare two

 byte[] 

knowing they’re the same length .
and what do you think about this ?

ReEditing:
enter image description here

the first is unsafe code .

second is first code i wrote (bool ArraysEqual())

and third is

myArray.SequenceEqual(otherArray); 

Now Take A good look at this
please Do allow me to announce, the winner is :

[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
static extern int memcmp(byte[] b1, byte[] b2, long count);

static bool ByteArrayCompare(byte[] b1, byte[] b2)
{
    // Validate buffers are the same length.     
    // This also ensures that the count does not exceed the length of either buffer.
    return b1.Length == b2.Length && memcmp(b1, b2, b1.Length) == 0;
}

@Chaos . Can u please post the implemetation of Your Random with my Pinvoke ?

enter image description here

  • 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-10T13:36:40+00:00Added an answer on June 10, 2026 at 1:36 pm

    if you use .NET > 3.0:

    myArray.SequenceEqual(otherArray);
    

    see MSDN – Enumerable.SequenceEqual

    if you want to use a custom “EqualityComparer” you can use MSDN – Enumerable.SequenceEqual with IEqualityComparer

    😉

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

Sidebar

Related Questions

There are two intents on the receiver side which are called from the same
There are two table s : one is the master and one the detail
There's a few previous questions on StackOverflow questioning how one goes about accessing local
There are two major fix engines: opensource QuickFix http://www.quickfixengine.org/ commercial Fix Antenna http://www.b2bits.com/trading_solutions/fix_engines/fix_engine_cpp.html What
there are a few intents i am looking to use and I am pretty
There doesn't seem to be any tried and true set of best practices to
There are two weird operators in C#: the true operator the false operator If
There are two popular closure styles in javascript. The first I call anonymous constructor
There are numerous Agile software development methods. Which ones have you used in practice
There are many methods to override, like initWithNibname: , awakeFromNib , loadView , viewDidLoad

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.