Skip to content

@chakrit /gist:2319253
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
using System;
namespace DummyCSharp
{
class MainClass
{
public static void Main (string[] args)
{
MyDateTime now = DateTime.Now;
Console.WriteLine ("Today's date is: " + (string)now);
}
}
public class MyDateTime
{
private DateTime _datetime;
private MyDateTime(DateTime dt) { _datetime = dt; }
// implicitly convertible to and from a DateTime
public static implicit operator DateTime(MyDateTime mdt)
{
return mdt._datetime;
}
public static implicit operator MyDateTime(DateTime dt)
{
return new MyDateTime(dt);
}
// must be explicitly converted to string
public static explicit operator string(MyDateTime mdt)
{
return mdt._datetime.ToString ("MM/dd/yyyy");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.