Custom literal suffixesfor C#

Topics: C# Language Design
May 4, 2014 at 6:31 PM
It would be handy to count with user-defined literal suffixes like in C++11:

http://en.cppreference.com/w/cpp/language/user_literal
May 11, 2014 at 1:00 PM
This is something I'd also appreciate.
For example we would specify units in literals, even create class instances from simple suffixed values.
This could be specified as special extension methods.
public static class Suffixes
{
    public static long operator"" Mb(this long size)
    {
        return size << 20;
    }
}

public static class Program
{
    static void Main()
    {
        var s = 1 Mb;
    }
}
(I had no idea regarding the exact syntax for method declaration, so anything else will probably be better)
Aug 31, 2014 at 10:41 PM
One issue is Uniary Operaters are prefix operators. So your "user literal" would be.
public static class Program
{
    static void Main()
    {
        var s = Mb 1;
    }
}