Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
GeneralRe: FREE .NET book :) :) :) Pin
Kannan Kalyanaraman12-Jul-03 7:24
Kannan Kalyanaraman12-Jul-03 7:24 
Generalthanks but.. Pin
peterchen13-Jul-03 10:48
peterchen13-Jul-03 10:48 
GeneralRe: thanks but.. Pin
leppie13-Jul-03 10:53
leppie13-Jul-03 10:53 
GeneralGraphics.DrawCurve() question Pin
Meysam Mahfouzi11-Jul-03 20:19
Meysam Mahfouzi11-Jul-03 20:19 
GeneralRe: Graphics.DrawCurve() question Pin
peterchen13-Jul-03 8:37
peterchen13-Jul-03 8:37 
GeneralRe: Graphics.DrawCurve() question Pin
Meysam Mahfouzi13-Jul-03 19:18
Meysam Mahfouzi13-Jul-03 19:18 
General2 not so # things Pin
leppie11-Jul-03 16:39
leppie11-Jul-03 16:39 
GeneralRe: 2 not so # things Pin
James T. Johnson11-Jul-03 17:32
James T. Johnson11-Jul-03 17:32 
leppie wrote:
Why cant you have a "params" parameter for the constructor of an attribute?

This compiled for me:

public class Foo : System.Attribute
{
  public int [] bar;
  public Foo(params int [] a)
  {
    bar = a;
  }
}
leppie wrote:
Why do you have to provide a constructor in an inherited abstract class where the base class does not have a default constructor?

I assume you mean the abstract class has a constructor that takes parameters rather than no constructor at all.

With C# if you don't supply a constructor, a default constructor is supplied for you. Similarly if you don't explicitly call the base class's constructor it attempts to call the default constructor for you.

In the case where the base class has only non-default constructors the compiler still tries to call one from the auto-generated default constructor for the child class, causing an error saying that method "Foo" has no overload that takes 0 arguments.

For example:

public class Foo
{
  public int bar;
  public Foo(int a)
  {
    bar = a;
  }
}

public class What
{
}
Results in the said error message.

Whether the base class is abstract doesn't play a part in this at all Wink | ;)

All testing on .NET v1.1

James

"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him

GeneralRe: 2 not so # things Pin
leppie11-Jul-03 18:11
leppie11-Jul-03 18:11 
GeneralRe: 2 not so # things Pin
Nick Parker11-Jul-03 18:30
protectorNick Parker11-Jul-03 18:30 
GeneralRe: 2 not so # things Pin
leppie11-Jul-03 18:45
leppie11-Jul-03 18:45 
GeneralRe: 2 not so # things Pin
Nick Parker12-Jul-03 5:26
protectorNick Parker12-Jul-03 5:26 
GeneralRe: 2 not so # things Pin
Heath Stewart11-Jul-03 18:31
protectorHeath Stewart11-Jul-03 18:31 
GeneralRe: 2 not so # things Pin
leppie11-Jul-03 19:29
leppie11-Jul-03 19:29 
GeneralRe: 2 not so # things Pin
Heath Stewart12-Jul-03 0:41
protectorHeath Stewart12-Jul-03 0:41 
GeneralRe: 2 not so # things Pin
James T. Johnson11-Jul-03 18:57
James T. Johnson11-Jul-03 18:57 
GeneralRe: 2 not so # things Pin
Heath Stewart11-Jul-03 18:21
protectorHeath Stewart11-Jul-03 18:21 
GeneralRe: 2 not so # things Pin
leppie11-Jul-03 18:29
leppie11-Jul-03 18:29 
GeneralOK, slap me silly and call me Susan - NOT Pin
leppie11-Jul-03 18:49
leppie11-Jul-03 18:49 
GeneralRe: 2 not so # things Pin
leppie11-Jul-03 19:40
leppie11-Jul-03 19:40 
GeneralRe: 2 not so # things Pin
Heath Stewart12-Jul-03 0:15
protectorHeath Stewart12-Jul-03 0:15 
GeneralRe: 2 not so # things Pin
leppie12-Jul-03 1:54
leppie12-Jul-03 1:54 
GeneralTooltips Pin
Nnamdi Onyeyiri11-Jul-03 12:25
Nnamdi Onyeyiri11-Jul-03 12:25 
GeneralRe: Tooltips Pin
Nick Parker11-Jul-03 18:33
protectorNick Parker11-Jul-03 18:33 
GeneralRe: Tooltips Pin
Nnamdi Onyeyiri11-Jul-03 23:27
Nnamdi Onyeyiri11-Jul-03 23:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.