Does anyone help me convert vb.net to c#

  • Thread starter Thread starter Alan Ho
  • Start date Start date
A

Alan Ho

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 find any method call Date, WeekdayName and CDate in C#. What can i
do?)
Thanks
 
Look into DateTime.ToString()
http://msdn.microsoft.com/library/d...ml/frlrfsystemdatetimeclasstostringtopic3.asp

Caveat: air code... I'd translate your code to be:

public string Helper(string MyObj)
{
DateTime mydate = DateTime.Parse(MyObj);
return mydate.ToString("dddd") + "<br>" + mydate.ToString(@"dd/MMMM");
}

I have no idea why you are passing in an Object instead of a string. If you
need to handle more types, use overloading.

public string Helper(DateTime mydate)
{
}
public string Helper(long mydate)
{
}
public string Helper(double mydate)
{
}

etc...

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
Back
Top