Home All Groups Group Topic Archive Search About

compiler going crazy or am I missing something?

Author
18 Oct 2005 4:16 PM
Lloyd Dupont
In my code I have something like that:

class RecipeFile
{
    // .....
}


class OptionPanel : UserControl
{
    public void Load(RecipeFile file)
    {
        // ....
    }
}

Now when I try to compile I get the following error message:
==
Error 2 Warning as Error:
'Cook.App.Dialogs.OptionCurrentFile.Load(Cook.Data.RecipeFile)' hides
inherited member 'System.Windows.Forms.UserControl.Load'. Use the new
keyword if hiding was intended.
L:\AppSource\eCookBook\eCookBook\Dialogs\OptionCurrentFile.cs 19 15
eCookBook
==

Now, I now there is a method call
class Control
{
    public void Load()
    {
        //....
    }
}
but there should be no ambiguity at all whatsoever with Load(RecipeFile
file)

is this a know bug (happening sometimes)?
I have .NET 2.0 beta 2

--
There are 10 kinds of people in this world. Those who understand binary and
those who don't.

Author
18 Oct 2005 4:58 PM
Nick Hertl
Your OptionPanel type extends the UserControl type.  UserControl has an
event named "Load" which prevents you from naming any methods this same
thing.  Either you need to name your method something else like
LoadRecipe or you need to not extend the UserControl type which already
has this Load event.
Author
19 Oct 2005 12:08 PM
Lloyd Dupont
different signature => different method..

--
There are 10 kinds of people in this world. Those who understand binary and
those who don't.
Show quote
"Nick Hertl" <nhe***@gmail.com> wrote in message
news:1129654722.551867.186930@g43g2000cwa.googlegroups.com...
> Your OptionPanel type extends the UserControl type.  UserControl has an
> event named "Load" which prevents you from naming any methods this same
> thing.  Either you need to name your method something else like
> LoadRecipe or you need to not extend the UserControl type which already
> has this Load event.
>
Author
19 Oct 2005 12:17 PM
Damien
Lloyd Dupont wrote:
> different signature => different method..
>
> --
Different beasts - Load on UserControl is an event, not a method.
You've never been able to have methods and events share the same name.
E.g. the following will not compile under VS2003:

Public Class Class1
  Public Event Load(ByVal Arg1 As Int32)

  Public Function Load(ByVal Arg1 As String)

  End Function
End Class

(Sorry, tend to do most of my stuff in VB, but shouldn't take too long
to translate demo into C# :-))

Damien
Author
20 Oct 2005 12:25 PM
Lloyd Dupont
Ow......
right.....
thanks!

--
There are 10 kinds of people in this world. Those who understand binary and
those who don't.
Show quote
"Damien" <Damien_The_Unbelie***@hotmail.com> wrote in message
news:1129724277.198278.145510@g47g2000cwa.googlegroups.com...
> Lloyd Dupont wrote:
>> different signature => different method..
>>
>> --
> Different beasts - Load on UserControl is an event, not a method.
> You've never been able to have methods and events share the same name.
> E.g. the following will not compile under VS2003:
>
> Public Class Class1
>  Public Event Load(ByVal Arg1 As Int32)
>
>  Public Function Load(ByVal Arg1 As String)
>
>  End Function
> End Class
>
> (Sorry, tend to do most of my stuff in VB, but shouldn't take too long
> to translate demo into C# :-))
>
> Damien
>
Author
18 Oct 2005 5:28 PM
Jon Skeet [C# MVP]
Lloyd Dupont <l*@NewsAccount.galador.net> wrote:
> In my code I have something like that:

<snip>

> but there should be no ambiguity at all whatsoever with Load(RecipeFile
> file)
>
> is this a know bug (happening sometimes)?
> I have .NET 2.0 beta 2

That certainly *sounds* like a bug to me.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Author
20 Oct 2005 12:27 PM
Lloyd Dupont
As Damien rightfully point out....
they are different beast..... (event EventHandler Control.Load & void
Control.Load(Datat data))
(it was a typo of mine to assume to write void Control.Load())

for example the code below won't compiler (oh.. right).
======
public class T2
{
public static event EventHandler Foo;

public static void Foo(int bar)
{
  Console.WriteLine("foo bar");
}

public static void Main()
{
  Foo(1);
}
}
======

--
There are 10 kinds of people in this world. Those who understand binary and
those who don't.
Show quote
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MPG.1dbf413293a66cd498c942@msnews.microsoft.com...
> Lloyd Dupont <l*@NewsAccount.galador.net> wrote:
>> In my code I have something like that:
>
> <snip>
>
>> but there should be no ambiguity at all whatsoever with Load(RecipeFile
>> file)
>>
>> is this a know bug (happening sometimes)?
>> I have .NET 2.0 beta 2
>
> That certainly *sounds* like a bug to me.
>
> Could you post a short but complete program which demonstrates the
> problem?
>
> See http://www.pobox.com/~skeet/csharp/complete.html for details of
> what I mean by that.
>
> --
> Jon Skeet - <sk***@pobox.com>
> http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
> If replying to the group, please do not mail me too

AddThis Social Bookmark Button