How to convert an Integer to Octal string in C# ?

You can easily format an integer to an octal string in C# using the Convert.ToString method.

Below is a sample sourcecode that demonstrates How to convert an Integer to Octal string in C# ?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    static class Program
    {
        static void Main()
        {
            FormatString();           
        }

        static void FormatString()
        {
            int intVal = 9;

            string formattedString = Convert.ToString(intVal, 8);
            MessageBox.Show(formattedString); 

        }
    }  
}