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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:21:30+00:00 2026-06-11T18:21:30+00:00

I try to learn F# and at this time i try to convert a

  • 0

I try to learn F# and at this time i try to convert a simple C# Function to F#
in some points i stuck at example var compressedData = new byte[memoryStream.Length]; < C#
here the full c# function

public static string CompressString(string text)
{
    byte[] buffer = Encoding.UTF8.GetBytes(text);
    var memoryStream = new MemoryStream();
    using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Compress, true))
    {
        gZipStream.Write(buffer, 0, buffer.Length);
    }

    memoryStream.Position = 0;

    var compressedData = new byte[memoryStream.Length];
    memoryStream.Read(compressedData, 0, compressedData.Length);

    var gZipBuffer = new byte[compressedData.Length + 4];
    Buffer.BlockCopy(compressedData, 0, gZipBuffer, 4, compressedData.Length);
    Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, gZipBuffer, 0, 4);
    return Convert.ToBase64String(gZipBuffer);
}

and here Mine half Translated version

let compress(text:string)=
    let buffer = Encoding.UTF8.GetBytes(text)
    use memoryStream = new MemoryStream()
    let gZipStream = new GZipStream(memoryStream, CompressionMode.Compress, true)
    gZipStream.Write(buffer, 0, buffer.Length)
    memoryStream.Position <- Convert.ToInt64(0)
    let compressedData = Array.init memoryStream.Length(fun i -> byte) //< Here i stuck
    memoryStream.Read(compressedData, 0, compressedData.Length)
    use gZipBuffer = (compressedData.Length + 4)

the last three days i have searched on google to solve my problem, but i didnt find any solution.
I hope someone here can help me 🙂
Thank you very much in advance

  • 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-11T18:21:31+00:00Added an answer on June 11, 2026 at 6:21 pm

    You’re looking for Array.zeroCreate.

    let compressedData = Array.zeroCreate (int memoryStream.Length)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with this example to try and learn Sencha Touch. I have
I am new to iOS programming and try to learn some of the basics
I'm new to multithreading and try to learn it through a simple program, which
I'm writing a simple IRC bot to try to learn more about Clojure, using
Hello I'm very new to OpenGlES and i have started to try to learn
I try to learn and implement a simple genetic algorithm library for my project.
I'm trying to learn gtkmm, and decided to try gtkmm 2.4 for the time
I try to learn writing parallel codes with thread library of c++11 so first
Bear with me as I try to learn more about .htaccess redirect rules -
I am coming from Java and try to learn Javascript right now. Doing that

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.