Why would you import the Microsoft.VisualBasic namespace into C# for
functionality that is very readily available natively as part of the
..NET class library?
using System;
public class DateTest
{
public static void Test()
{
Console.WriteLine(MyDateFormat(DateTime.Now));
Console.WriteLine(MyDateFormat("1/1"));
}
public static string MyDateFormat(object obj)
{
DateTime d;
if (obj is DateTime)
{
d = (DateTime)obj;
}
else if (obj is string)
{
d = DateTime.Parse((string)obj);
}
else
{
throw new ArgumentException(obj.GetType().FullName + " no valid
for Format");
}
return d.ToString("dddd") + "<br>" + d.ToString("d/m");
}
}
Sam
On Sat, 2 Apr 2005 14:52:48 +0200, "Herfried K. Wagner [MVP]"
<hi***************@gmx.at> wrote:
"Alan Ho" <gt*********@yahoo.com.hk> schrieb: Function Helper(ByVal obj As Object) As String
Dim thisDate As Date = CDate(obj)
Return WeekdayName(Weekday(thisDate, vbSunday), False, vbSunday) &
"<br>" & _
thisDate.Day & "/" & thisDate.Month
End Function
(I can't find any method call Date, WeekdayName and CDate in C#. What can
i
do?)
Although your question is off-topic here:
'Date' -> 'DateTime'. In order to use functions like 'Weekday' and
'WeekdayName' add a reference to "Microsoft.VisualBasic.dll" and import
'Microsoft.VisualBasic.DateAndTime'. Instead of 'CDate' use
'DateTime.Parse'/'DateTime.ParseExact' or similar.
B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.