Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//Rextester.Program.Main is the entry point for your code. Don't change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Enter the column number:");
string columnNo = Console.ReadLine();
int columnNumber = int.Parse(columnNo);
int dividend = columnNumber;
string columnName = String.Empty;
int modulo;
while (dividend > 0)
{
modulo = (dividend - 1) % 26;
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
dividend = (int)((dividend - modulo) / 26);
}
Console.WriteLine("Column ID: " + columnName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment