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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:04:32+00:00 2026-05-22T02:04:32+00:00

I need help with translating some code from VB to C#. Public Function ToBase36(ByVal

  • 0

I need help with translating some code from VB to C#.

Public Function ToBase36(ByVal IBase36 As Double) As String
    Dim Base36() As String = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
    Dim v As String
    Dim i As Decimal
    Do Until IBase36 < 1
        i = IBase36 Mod 36
        v = Base36(i) & v
        IBase36 = Math.DivRem(Long.Parse(IBase36), 36, Nothing)
    Loop
    Return v

End Function

My problem is how type conversion works in VB, and this line gives me most trouble since IBase36 is a double, Math.DivRem() in this case should return long and Long.Parse() need string.

IBase36 = Math.DivRem(Long.Parse(IBase36), 36, Nothing)

Here is my translated, working code thanks to the JaredPar and others

    public static string ToBase36(double IBase36)
    {
        string[] Base36 = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
        string v = null;
        long i = default(long);
        while (!(IBase36 < 1))
        {
            IBase36 = Convert.ToDouble(Math.DivRem(Convert.ToInt64(IBase36), 36, out i));
            v = Base36[i] + v;
        }
        return v;
    }
  • 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-22T02:04:33+00:00Added an answer on May 22, 2026 at 2:04 am

    To translate it’s important to understand first how the VB.Net code functions. Under the hood it will essentially generate the following

    Dim unused As Long
    IBase36 = CDbl(Math.DivRem(Long.Parse(CStr(IBase36)), 36, unused)
    

    Note: The unused variable is necessary because the third argument is an out. This is an important difference when translating to C#.

    The most natural C# equivalent of the above is

    long unused;
    IBase36 = Convert.ToDouble(Math.DivRem(Long.Parse(IBase36.ToString()), 36, out unused);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need help with disk_total_space function.. i have this on my code <?php $sql=select
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need help understanding some C++ operator overload statements. The class is declared like
I need help to replace all \n (new line) caracters for in a String,
Need help for implementing PUSH notification in android. wanted to know from which android
Need help parsing... In my code, I have a method that returns url.getHost();. But
I need help with this route map routes.MapRoute(Blog_Archive, Blog/Archive/{year}/{month}/{day}, new { controller = Blog,
I need help getting my head around the difference between my current OOP notion
I need help with the best practice to localize asp mvc apps, I saw
I really need help with interfaces in general... Any resources that you guys would

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.