format date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I allow the use select a date from a calender control and I want to format
the date.
I have this:

Session["date"] = Format("calender.selectedDate, "dd/yyyy");

and i'm getting an error on Format when i compile:
the error is:
The Name Format does not exist in class or namespace.

what do i need to do different in C# to do this then VB.NET
 
Format("xxx", "yyy") works in VB.Net because the Microsoft.VisualBasic
Runtime is referenced. You could also referece this from your C# project
which would then let you use the same Microsoft.VisualBasic.Strings.Format()
method (which is exactly what you are doing with Format() in VB.Net).

A better alternative in my mind (since it'll work in both C# and VB.Net with
no additional work) is to simply use
calender.selectedData.ToString("dd/yyyy")

Karl
 
Back
Top