format 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
 
K

Karl Seguin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top