By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,694 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,694 IT Pros & Developers. It's quick & easy.

Does anyone help me convert vb.net to c#

P: n/a
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?)
Thanks

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a

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.
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.