Skip to content

Instantly share code, notes, and snippets.

@danielcooperxyz
Created September 11, 2017 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielcooperxyz/675c8172678d448c63594a40e95d8980 to your computer and use it in GitHub Desktop.
Save danielcooperxyz/675c8172678d448c63594a40e95d8980 to your computer and use it in GitHub Desktop.
//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