Click here to Skip to main content
15,921,697 members
Home / Discussions / C#
   

C#

 
GeneralRe: is there a quick and dirty way to add 'st' 'rd' 'th' to numbers? Pin
Colin Angus Mackay26-Dec-05 10:41
Colin Angus Mackay26-Dec-05 10:41 
GeneralRe: is there a quick and dirty way to add 'st' 'rd' 'th' to numbers? Pin
Joshua Lunsford26-Dec-05 13:58
Joshua Lunsford26-Dec-05 13:58 
GeneralRe: is there a quick and dirty way to add 'st' 'rd' 'th' to numbers? Pin
Robert Rohde26-Dec-05 11:11
Robert Rohde26-Dec-05 11:11 
NewsFinally proper! I hope! :) Pin
leppie26-Dec-05 10:41
leppie26-Dec-05 10:41 
GeneralRe: is there a quick and dirty way to add 'st' 'rd' 'th' to numbers? Pin
Rob Philpott26-Dec-05 11:16
Rob Philpott26-Dec-05 11:16 
GeneralRe: is there a quick and dirty way to add 'st' 'rd' 'th' to numbers? Pin
leppie26-Dec-05 11:35
leppie26-Dec-05 11:35 
GeneralRe: is there a quick and dirty way to add 'st' 'rd' 'th' to numbers? Pin
Colin Angus Mackay26-Dec-05 14:09
Colin Angus Mackay26-Dec-05 14:09 
AnswerRe: is there a quick and dirty way to add 'st' 'rd' 'th' to numbers? Pin
manasvarpe26-Dec-05 18:05
manasvarpe26-Dec-05 18:05 
I think that for any number whenever the digit at tenth place is '1' then 'th' is always appended to the number. For all other numbers ending with 1,2,3 digits are appended with 'st','nd','rd' respectively for all other digits 'th' is appended.

And this is my code.

public string Dirty(int number)
{
int num=number%100;
int tenplace=num/10;

if(tenplace==1)
{
return number + "th";
}
switch (number%10)
{
case 1:
return number + "st";
case 2:
return number + "nd";
case 3: return number + "rd";
default: return number + "th";
}
}

GeneralRe: is there a quick and dirty way to add 'st' 'rd' 'th' to numbers? Pin
peshkunta26-Dec-05 18:59
peshkunta26-Dec-05 18:59 
GeneralRe: is there a quick and dirty way to add 'st' 'rd' 'th' to numbers? Pin
manasvarpe26-Dec-05 22:44
manasvarpe26-Dec-05 22:44 
Newsconnect serial comm port with VS.NET2003 Pin
sharapova26-Dec-05 6:50
sharapova26-Dec-05 6:50 
Question.net 2.0 SqlDependency Pin
fmardani26-Dec-05 6:45
fmardani26-Dec-05 6:45 
AnswerRe: .net 2.0 SqlDependency Pin
Xodiak26-Dec-05 14:53
Xodiak26-Dec-05 14:53 
GeneralRe: .net 2.0 SqlDependency Pin
fmardani26-Dec-05 20:43
fmardani26-Dec-05 20:43 
QuestionProblem with Label control Pin
naglbitur26-Dec-05 5:56
naglbitur26-Dec-05 5:56 
AnswerRe: Problem with Label control Pin
Curtis Schlak.26-Dec-05 6:13
Curtis Schlak.26-Dec-05 6:13 
GeneralRe: Problem with Label control Pin
naglbitur26-Dec-05 6:28
naglbitur26-Dec-05 6:28 
GeneralRe: Problem with Label control Pin
Curtis Schlak.26-Dec-05 7:03
Curtis Schlak.26-Dec-05 7:03 
GeneralRe: Problem with Label control Pin
naglbitur26-Dec-05 6:45
naglbitur26-Dec-05 6:45 
GeneralRe: Problem with Label control Pin
Curtis Schlak.26-Dec-05 7:04
Curtis Schlak.26-Dec-05 7:04 
QuestionContext menu strips event sources? Pin
Dominik Reichl26-Dec-05 4:57
Dominik Reichl26-Dec-05 4:57 
AnswerRe: Context menu strips event sources? Pin
Darryl Borden29-Dec-05 9:17
Darryl Borden29-Dec-05 9:17 
QuestionRegarding SQL Database Pin
manojk_batra26-Dec-05 1:48
manojk_batra26-Dec-05 1:48 
AnswerRe: Regarding SQL Database Pin
Colin Angus Mackay26-Dec-05 2:19
Colin Angus Mackay26-Dec-05 2:19 
GeneralRe: Regarding SQL Database Pin
manojk_batra26-Dec-05 17:30
manojk_batra26-Dec-05 17:30 

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.