How to convert an integer to a string in base b with C#

1 Answer

0 votes
using System;

class IntegerToStringBase
{
    static void Main()
    {
        int number = 255; 
        int baseValue = 16; 

        // Convert integer to string in the specified base and make it uppercase
        string result = Convert.ToString(number, baseValue).ToUpper();

        Console.WriteLine($"Number in base {baseValue}: {result}");
    }
}



/*
run:

Number in base 16: FF

*/

 



answered Aug 17, 2025 by avibootz

Related questions

1 answer 115 views
115 views asked Mar 17, 2025 by avibootz
3 answers 186 views
186 views asked Feb 10, 2021 by avibootz
1 answer 102 views
2 answers 120 views
...