I want an internal static implicit operator :)

February 22, 2006 at 7:02 pm | Posted in C#, GIMP | 2 Comments

Here is the problem: I have a struct of type GimpRGB which is basically the C# version of the same structure in C. I need this because I have to marshall functions between C and C#. Now in C# I use a class RGB which encapsulates this GimpRGB struct. In the API of my library GIMP# I don’t want to see this GimpRGB struct, so I use an internal property in the RGB class to get this struct:

internal GimpRGB GimpRGB
return _rgb;
This works, but looks slightly clumsy. Now I thought it would be a good idea to create a implicit operator that could convert from RGB to GimpRGB. Of course I don’t want this operator to be visible outside the assembly, so I declared:

internal static implicit operator GimpRGB(RGB rgb)
return rgb._rgb;
Somehow this isn’t allowed in C# 😦



RSS feed for comments on this post. TrackBack URI

  1. what error are you getting? normally C# compiler is very good at reporting errors if it can’t do something.

  2. error CS0106: The modifier `internal’ is not valid for this item
    Compilation failed: 1 error(s), 0 warnings

    The problem is that for some obscure reason this isn’t allowed in C#.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: