|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
compiler going crazy or am I missing something?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. 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. different signature => different method..
-- Show quoteThere are 10 kinds of people in this world. Those who understand binary and those who don't. "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. > 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 Ow......
right..... thanks! -- Show quoteThere are 10 kinds of people in this world. Those who understand binary and those who don't. "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 > 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 That certainly *sounds* like a bug to me.> file) > > is this a know bug (happening sometimes)? > I have .NET 2.0 beta 2 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 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); } } ====== -- Show quoteThere are 10 kinds of people in this world. Those who understand binary and those who don't. "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 |
|||||||||||||||||||||||