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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:50:08+00:00 2026-05-12T06:50:08+00:00

I probably should have just put all this in one question, sorry for that

  • 0

I probably should have just put all this in one question, sorry for that 🙁

Second error

Ok, this should be the end of errors (hopefully):

private static string getCRC(string input, bool appendDate)
{
    string toEnc = string.Format("{0}{1}", input, appendDate == true ? string.Format("{0:yyyyMMdd}", System.DateTime.Now) : "");
    System.IO.MemoryStream mStream = new System.IO.MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(toEnc), false);
    
    CRC32 oCRC = new CRC32();
    return oCRC.GetCrc32(((System.IO.Stream)mStream)).ToString();
}

Error is on the return line:

Compiler Error Message: CS1502: The best overloaded method match for ‘CRC.CRC32.GetCrc32(ref System.IO.Stream)’ has some invalid arguments

Here is the function it is referring to:

public UInt32 GetCrc32(ref System.IO.Stream stream)
{
    //Dim crc32Result As Integer = &HFFFFFFFF
    UInt32 crc32Result = UInt32.MaxValue;

    try
    {

        byte[] buffer = new byte[BUFFER_SIZE];
        int readSize = BUFFER_SIZE;

        int count = stream.Read(buffer, 0, readSize);
        int i;
        UInt32 iLookup;
        //Dim tot As Integer = 0
        while ((count > 0))
        {
            for (i = 0; i <= count - 1; i++)
            {
                iLookup = (crc32Result & 0xff) ^ buffer[i];
                //crc32Result = ((crc32Result And &HFFFFFF00) \ &H100) And &HFFFFFF                     ' nasty shr 8 with vb :/
                crc32Result = ((UInt32)((crc32Result & 4294967040L) / 256) & UInt32.MaxValue);
                // nasty shr 8 with vb :/
                crc32Result = crc32Result ^ crc32Table[iLookup];
            }
            count = stream.Read(buffer, 0, readSize);
        }
    }
    catch (Exception ex)
    {
        HttpContext.Current.Response.Output.Write(string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace));
        System.Diagnostics.Debugger.Break();
    }

    return (~crc32Result);

}

As you can see I tried to cast the memorystream as a stream, but I don’t think it liked that too much.

First error

(solved here)

If you have not seen my last couple of questions, I have a CRC function written in VB.NET. I used an online converter to convert it over to C#. Here is the original VB code:

Public Sub New()
    Dim dwPolynomial As UInt32 = 3988292384
    Dim i As Integer, j As Integer

    ReDim crc32Table(256)
    Dim dwCrc As UInt32

    For i = 0 To 255
        dwCrc = i
        For j = 8 To 1 Step -1
            If (dwCrc And 1) Then
                dwCrc = ((dwCrc And &HFFFFFFFE) \ 2&) And &H7FFFFFFF
                dwCrc = dwCrc Xor dwPolynomial
            Else
                dwCrc = ((dwCrc And &HFFFFFFFE) \ 2&) And &H7FFFFFFF
            End If
        Next j
        crc32Table(i) = dwCrc
    Next i
End Sub

Here is my converted code. I fixed a few of the errors I was having but there are few more that I cannot figure out:

public CRC32()
{
    UInt32 dwPolynomial = ((UInt32)3988292384L);
    int i;
    int j;

    UInt32[] crc32Table;
    crc32Table = new UInt32[256];
    UInt32 dwCrc;

    for (i = 0; i <= 255; i++)
    {
        dwCrc = ((UInt32)i);
        for (j = 8; j >= 1; j -= 1)
        {
            if ((dwCrc & 1))
            {
                dwCrc = ((dwCrc & 0xfffffffe) / 2L) & 0x7fffffff;
                dwCrc = dwCrc ^ dwPolynomial;
            }
            else
            {
                dwCrc = ((dwCrc & 0xfffffffe) / 2L) & 0x7fffffff;
            }
        }
        crc32Table[i] = dwCrc;
    }
}

The first error is on this line:

Compiler Error Message: CS0030: Cannot convert type ‘uint’ to ‘bool’

if ((dwCrc & 1))

Should I be comparing these two values with a different operator? I am not too sure about why the & operator is there to be honest.

Thanks SO.

  • 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-12T06:50:08+00:00Added an answer on May 12, 2026 at 6:50 am

    There’s no implicit integer-to-boolean conversion in C#. You have to compare against 0 explicity:

    if ((dwCrc & 1) != 0) ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the feeling this is probably something I should know but I can't
Probably a really simple one this - I'm starting out with C# and need
Probably a long question for a simple solution, but here goes... I have a
Probably an easy one: Are there any rules of thumb or pointers that could
This probably has a simple answer, but I must not have had enough coffee
This probably sounds really stupid but I have noo idea how to implement jquery's
This question would probably apply equally as well to other languages with C-like multi-line
This is my first question here on stackoverflow, so I hope that I am
First of all, let me just say that I'm using the PHP framework Yii,
I have been wondering how much content you should typically allow a CMS to

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.