Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: alphanumeric counter Pin
Matt T Heffron14-Feb-13 9:28
professionalMatt T Heffron14-Feb-13 9:28 
GeneralRe: alphanumeric counter Pin
Jibesh14-Feb-13 9:29
professionalJibesh14-Feb-13 9:29 
GeneralRe: alphanumeric counter Pin
Matt T Heffron14-Feb-13 9:13
professionalMatt T Heffron14-Feb-13 9:13 
QuestionRe: alphanumeric counter Pin
Matt T Heffron14-Feb-13 9:52
professionalMatt T Heffron14-Feb-13 9:52 
AnswerRe: alphanumeric counter Pin
Angela Scheuvront14-Feb-13 10:15
Angela Scheuvront14-Feb-13 10:15 
GeneralRe: alphanumeric counter Pin
Matt T Heffron14-Feb-13 10:25
professionalMatt T Heffron14-Feb-13 10:25 
GeneralRe: alphanumeric counter Pin
Angela Scheuvront15-Feb-13 1:45
Angela Scheuvront15-Feb-13 1:45 
AnswerRe: alphanumeric counter Pin
Richard Deeming15-Feb-13 1:37
mveRichard Deeming15-Feb-13 1:37 
This looks like a standard Excel column number followed by a four-digit decimal part. Assuming you need the code in C#, something like this should work:
C#
static string ConvertNumber(int number)
{
   if (number < 0) throw new ArgumentOutOfRangeException();

   int decimalPart;
   int columnNumber = Math.DivRem(number, 10000, out decimalPart) + 1;
   int length = 5 + (int)Math.Floor(Math.Log(columnNumber, 26));

   int resultIndex = length - 1;
   char[] result = new char[length];

   for (int i = 0; i < 4; i++)
   {
      int remainder;
      decimalPart = Math.DivRem(decimalPart, 10, out remainder);
      result[resultIndex] = (char)('0' + remainder);
      resultIndex--;
   }

   while (columnNumber != 0)
   {
      int remainder = (columnNumber - 1) % 26;
      columnNumber = (columnNumber - remainder - 1) / 26;
      result[resultIndex] = (char)('A' + remainder);
      resultIndex--;
   }

   resultIndex++;
   return new string(result, resultIndex, length - resultIndex);
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: alphanumeric counter Pin
Matt T Heffron15-Feb-13 7:39
professionalMatt T Heffron15-Feb-13 7:39 
QuestionStreamWriter.WriteAsync Pin
wizardzz14-Feb-13 6:15
wizardzz14-Feb-13 6:15 
AnswerRe: StreamWriter.WriteAsync Pin
Dave Kreskowiak14-Feb-13 7:31
mveDave Kreskowiak14-Feb-13 7:31 
GeneralRe: StreamWriter.WriteAsync Pin
wizardzz14-Feb-13 8:33
wizardzz14-Feb-13 8:33 
GeneralRe: StreamWriter.WriteAsync Pin
wizardzz14-Feb-13 8:55
wizardzz14-Feb-13 8:55 
Questionsingle selection of radio buttons in a table Pin
Member 258173814-Feb-13 4:36
Member 258173814-Feb-13 4:36 
AnswerRe: single selection of radio buttons in a table Pin
Richard MacCutchan14-Feb-13 4:58
mveRichard MacCutchan14-Feb-13 4:58 
AnswerRe: single selection of radio buttons in a table Pin
Alan Balkany14-Feb-13 5:04
Alan Balkany14-Feb-13 5:04 
QuestionBetter code Pin
ali_heidari_14-Feb-13 3:57
ali_heidari_14-Feb-13 3:57 
AnswerRe: Better code Pin
Alan Balkany14-Feb-13 4:50
Alan Balkany14-Feb-13 4:50 
GeneralRe: Better code Pin
Manfred Rudolf Bihy14-Feb-13 5:28
professionalManfred Rudolf Bihy14-Feb-13 5:28 
QuestionRe: Better code Pin
ali_heidari_14-Feb-13 5:40
ali_heidari_14-Feb-13 5:40 
AnswerRe: Better code Pin
Alan Balkany14-Feb-13 5:50
Alan Balkany14-Feb-13 5:50 
GeneralRe: Better code Pin
Dave Kreskowiak14-Feb-13 6:09
mveDave Kreskowiak14-Feb-13 6:09 
GeneralRe: Better code Pin
Espen Harlinn14-Feb-13 6:14
professionalEspen Harlinn14-Feb-13 6:14 
GeneralRe: Better code Pin
Alan Balkany14-Feb-13 6:40
Alan Balkany14-Feb-13 6:40 
GeneralRe: Better code Pin
ali_heidari_14-Feb-13 12:02
ali_heidari_14-Feb-13 12:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.