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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:25:11+00:00 2026-06-19T03:25:11+00:00

I have an in-memory byte[] and need to locate the offset where 13 and

  • 0

I have an in-memory byte[] and need to locate the offset where 13 and 10 are. I will then use the following to extract that line:

 String oneLine = Encoding.ASCII.GetString(bytes, 0, max);

What is the fastest way to search for the two bytes on a x64 bit computer? ..and convert it to a string?

Is there anything I can do other than iterating through each byte, scanning for 13 and then scan for 10?

// Disclaimer: 
// This is just for my curiosity.  Perhaps I'll gain a better understanding of
// how .NET interfaces with RAM, the CPU instructions related to comparisons, etc.
//  
// I don't suspect a performance problem, but I do suspect a lack of understanding
// (on my part) on how C# does low-level operations.
  • 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-19T03:25:12+00:00Added an answer on June 19, 2026 at 3:25 am

    Not sure if it will be ‘the fastest way’ but you can look at Boyer-Moore algorithm to find the indexes of the required values.

    Have a look at this SO thread Search longest pattern in byte array in C#

    Boyer-Moore would be better than a linear array traversal because it can skip elements depending on the length of you ‘needle’ and it gets better as the ‘haystack’ gets bigger. HTH.

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

Sidebar

Related Questions

I have a bytearray that I need to use as a key to a
I have a string that I want as a byte array. So far I
I have a four byte DWORD that I need to split into four different
I have a memory stream that contains a zip file in byte[] format. Is
I need to create a WCF Service that will have a download file function.
Why do computers have byte-addressable memory, and not 4-byte-addressable memory (or 8-byte-addressable memory for
I have a memory block that is divided into a series of location that
I have vague memory of a screenshot of a VS plugin that colors different
I have a license file that I need to access at runtime in order
I have some memory that has been allocated on device that is just a

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.