Re: how do you overload methods...
From: Mark Broadbent (nospam_at_nospam.com)
Date: 11/06/04
- Next message: Santi: "Re: Get a reference to an object's base type"
- Previous message: ShaneB: "Re: Printing PDF from Process.Start( , ) without user prompt"
- In reply to: Thomas P. Skinner [MVP]: "Re: how do you overload methods..."
- Next in thread: Thomas P. Skinner [MVP]: "Re: how do you overload methods..."
- Reply: Thomas P. Skinner [MVP]: "Re: how do you overload methods..."
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 6 Nov 2004 20:17:18 -0000
I believe that the constructor of the TreeViewCollection has been set to
private so effectively it can't be inherited.
The error message is a bit misleading though (it suggests that there is a
public constructor that does not have zero args - and hence in that case you
would be able to call it from your derived class) .
see for instance...
http://www.groupsrv.com/dotnet/viewtopic.php?t=16350
Hope this helps
Br,
Mark.
P.S.
Benny, although this is really something that is open to your/ your company
preference, when naming types you should (IMHO) not prefix them with
"t" -that is really a Delphi thing (but if it works for you then please
ignore my advice).
P.P.S.
You mention that you do not understand overloading, well in essence creating
an overload means that you are adding an additional function call to a class
which has the same name that is distinguished by it's type signature.
For instance
public void SayHello()
{SayHello();} //just calling overload method to save code in class
public void SayHello(string name)
{ string display = "Hello";
if name.Length > 0
display += name;
Console.WriteLine(display);
}
Which will mean that the Class would provide two method calls..
1 that allows you to SayHello without any arguments and the other to allow
you to SayHello with a string argument.
***I think you are also getting a little bit confused with overloading and
overriding - they are two DIFFERENT concepts. You should ideally read up on
both since they are crucial to good OOP***
"Thomas P. Skinner [MVP]" <tom@bu.edu> wrote in message
news:uKdDEgCxEHA.2788@TK2MSFTNGP15.phx.gbl...
> An overloaded method is a method that differs from all methods of the same
> name in so far as it has a different number or types of its arguments. A
> different return type does not constitute an overload. If you get an error
> stating that no overload has 0 arguments then you are calling a method
> with no arguments and you have no overloaded method that takes zero
> arguments. Either instantiate the class with a constructor call with
> arguments or provide an explicit constructor with zero arguments. In C# if
> you provide an overloaded constructor you no longer get a default
> constructor (zero arguments) and need to provide one. I think this is your
> problem.
>
> Thomas P. Skinner [MVP]
>
> "Benny Raymond" <benny@pocketrocks.com> wrote in message
> news:%238Ngd0BxEHA.4004@tk2msftngp13.phx.gbl...
>> I'm trying to change the way a treeview works just a bit, i'm pretty new
>> to C# and now i'm running into overloading. I tried the following code
>> and it's yelling at me saying that no overload method takes 0 arguments.
>>
>> #region tViewNodeCollection
>> public class tViewNodeCollection : TreeNodeCollection
>> {
>> private tView _owner;
>> private tViewNode _parent;
>> /// <summary>
>> /// Create a collection within a tViewItem
>> /// </summary>
>> /// <param name="parent"></param>
>> public tViewNodeCollection(tViewNode parent)
>> {
>> _parent = parent;
>> }
>> /// <summary>
>> /// Create a new instance of tViewNodeCollection
>> /// </summary>
>> /// <param name="owner"></param>
>> public tViewNodeCollection(tView owner)
>> {
>> _owner = owner;
>> }
>> /// <summary>
>> /// Create a new instance of tViewNodeCollection
>> /// </summary>
>> /// <param name="owner"></param>
>> public tViewNodeCollection(tView owner, tViewNode parent)
>> {
>> _owner = owner;
>> _parent = parent;
>> }
>> }
>> #endregion
>>
>>
>> so then I tried a series of different :this(something) but that started
>> scaring me since I really don't understand overloading - Could someone
>> shed some light on this for me?
>
>
- Next message: Santi: "Re: Get a reference to an object's base type"
- Previous message: ShaneB: "Re: Printing PDF from Process.Start( , ) without user prompt"
- In reply to: Thomas P. Skinner [MVP]: "Re: how do you overload methods..."
- Next in thread: Thomas P. Skinner [MVP]: "Re: how do you overload methods..."
- Reply: Thomas P. Skinner [MVP]: "Re: how do you overload methods..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|