2009-11-03 10 views

답변

1

이 아마 가장 좋은 방법을 : -

private static string[] dayText = new string[] 
{"First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth", 
"Nineth", "Tenth", "Eleventh", "Twelveth", "Thirteenth", "Fourteenth", "Fifteenth", 
    "Sixteenth", "Seventeenth", "Eighteenth", "Nineteenth", "Twentieth", "Twenty first", 
"Twenty second", "Twenty third", "Twenty fourth", "Twenty fifth", "Twenty sixth", 
"Twenty seventh", "Twenty eighth", "Twenty nineth", "Thirtieth", "Thirty first"}; 

public static string DayInWords(int day) 
{ 
    //assertion code here 
    return dayText[day-1]; 
} 

... 
string result = DayInWords(myDate.Day) + myDate.ToString(" MMM yyyy"); 
0

나는 내장 함수를 모른다. 그러나 고려해야 할 것은 31 일뿐입니다. 1에서 31을 수동으로 단어로 대체 한 함수를 만드는 것은 쉽습니다. 다음과 같이 월과 올해 추가 :

Function foobar(ByVal mydate As Date) As String 

Dim result As String = "" 
Select Case mydate.Day 
    Case 1 
     result = "First" 
     Case 2 
      result = "Second" 
     Case 3 
      result = "Third" 

     ... etc ... 

     Case 31 
     result = "Thirty-First" 
End Select 
Return result & " " & mydate.ToString("MMMM yyyy") 
End Function 
관련 문제