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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:34:07+00:00 2026-05-30T23:34:07+00:00

Is there a ready made function to be able to do base conversions in

  • 0

Is there a ready made function to be able to do base conversions in c#? I am looking to convert from base 26 and base base 27 numbers to base 10. I can do it on paper but i am not a very experienced programmer and would rather not do it from scratch if possible. Thanks!

  • 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-30T23:34:08+00:00Added an answer on May 30, 2026 at 11:34 pm

    There is a ready-made function to convert numbers from base 2, 8 or 16 to base 10 ( Convert.ToInt32). If you want to convert numbers from base 26 or base 27 to base 10, you’ll have to do it yourself.

    Now, I’ve never heard of base 26 numbers, so I’m just going to assume the ‘digits’ are A to Z (A having a value of 0, and Z having a decimal value of 25). To convert from base 26 to base 10 you should do the following:

    string charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int GetDigitValue(char digit)
    {
        return charset.IndexOf(digit);
    }
    int ConvertFromBase26(string number)
    {
        int result = 0;
        foreach(char digit in number)
            result = result * charset.Length + GetDigitValue(digit);
    
        return result;
    }
    

    To convert from base 27, just add whatever character represents 26.

    Note: There’s no error correction (you can convert the string “$#$@#$@” which will get you a nice negative number), and GetDigitValue is rather inefficient and should be replaced with a lookup table if you plan to do these conversions a lot.

    EDIT: A LINQ version, just for kicks.

    Again, no efficient lookup and no error correction, assuming the string consists only of legal digits.

    string charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int ConvertFromBase(string charset, string number)
    {
        return number.Select(c=>charset.IndexOf(c)).Aggregate(0, (x, y) => x*charset.Length +y);
    }
    

    I think the first version is more readable, though.

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

Sidebar

Related Questions

Is there a ready-to-use C# interpreter out there, that is does not rely on
I've written a small lightbox plugin for jQuery (yes, there are several ready made
I have made this script $(document).ready(function(){ $(div#tabs a).hover(function(){ rod = this.id $('div.tabber').hide(); $('#tabber_' +
I have an ajax call in my document ready function. But in about 1
I wanted to add a function to my Slim application but I'm not familiar
is there any ready to go solution within the microsoft framework, regarding conversion of
Is there any ready-to-go docbook editor for web applications out there? I'm thinking of
Is there any framework/library for using ASP.NET Membership Provider with confirmation email, something ready
When I start up Eclipse, ready to rock, I have to sit there and
Is there a read only property for a checkbox? Because I can still tick

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.