polytronicgr / sharpkit

Automatically exported from code.google.com/p/sharpkit
0 stars 0 forks source link

Implicit / explicit operator overload #294

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have problem with implicit operator, I would like to do something like this 
(in C#):

Url url = (Url)"http://www.google.com";

Url is struct like this:

public struct Url
{
    public string Content;

    public Url(string content)
    {
        Content = content;
    }

    public static implicit operator Url(string content)
    {
        return new Url(content);
    }
}

This struct is compiled to JS correctly, including op_Implicit function, but 
this function isn't called when I try to make implicit conversion and the first 
line is compiled this way:

var url = "http://www.google.com";

Original issue reported on code.google.com by DanelK...@gmail.com on 6 Jun 2013 at 8:45