Click here to Skip to main content
15,906,766 members
Home / Discussions / C#
   

C#

 
GeneralRe: Tracing - Perfomance impact. Pin
Guffa14-Nov-08 18:17
Guffa14-Nov-08 18:17 
GeneralRe: Tracing - Perfomance impact. Pin
Scott Bruno15-Nov-08 8:08
Scott Bruno15-Nov-08 8:08 
AnswerRe: Tracing - Perfomance impact. Pin
Pete O'Hanlon14-Nov-08 10:39
mvePete O'Hanlon14-Nov-08 10:39 
GeneralRe: Tracing - Perfomance impact. Pin
Member 232448314-Nov-08 13:14
Member 232448314-Nov-08 13:14 
QuestionUrgent Help Dataset DB Update Pin
NewbieGL14-Nov-08 5:17
NewbieGL14-Nov-08 5:17 
AnswerRe: Urgent Help Dataset DB Update Pin
Vimalsoft(Pty) Ltd14-Nov-08 7:16
professionalVimalsoft(Pty) Ltd14-Nov-08 7:16 
QuestionAnaimated Graphics Pin
Rafone14-Nov-08 5:13
Rafone14-Nov-08 5:13 
AnswerRe: Anaimated Graphics Pin
Wendelius14-Nov-08 8:10
mentorWendelius14-Nov-08 8:10 
QuestionEventLog Crap Pin
#realJSOP14-Nov-08 4:54
professional#realJSOP14-Nov-08 4:54 
AnswerRe: EventLog Crap Pin
J4amieC14-Nov-08 4:59
J4amieC14-Nov-08 4:59 
AnswerRe: EventLog Crap Pin
Wendelius14-Nov-08 7:49
mentorWendelius14-Nov-08 7:49 
QuestionDesktop App or Access 2003? Pin
hellbentuk14-Nov-08 4:44
hellbentuk14-Nov-08 4:44 
AnswerRe: Desktop App or Access 2003? Pin
mark_w_14-Nov-08 5:11
mark_w_14-Nov-08 5:11 
AnswerRe: Desktop App or Access 2003? Pin
Wendelius14-Nov-08 7:56
mentorWendelius14-Nov-08 7:56 
AnswerRe: Desktop App or Access 2003? Pin
Paul Conrad14-Nov-08 8:48
professionalPaul Conrad14-Nov-08 8:48 
GeneralRe: Desktop App or Access 2003? Pin
hellbentuk15-Nov-08 1:41
hellbentuk15-Nov-08 1:41 
QuestionException Constructor Pin
George_George14-Nov-08 2:17
George_George14-Nov-08 2:17 
AnswerRe: Exception Constructor Pin
J4amieC14-Nov-08 2:23
J4amieC14-Nov-08 2:23 
GeneralRe: Exception Constructor Pin
George_George16-Nov-08 2:05
George_George16-Nov-08 2:05 
AnswerRe: Exception Constructor Pin
Le centriste14-Nov-08 5:44
Le centriste14-Nov-08 5:44 
GeneralRe: Exception Constructor Pin
George_George16-Nov-08 2:07
George_George16-Nov-08 2:07 
GeneralRe: Exception Constructor Pin
Le centriste16-Nov-08 2:33
Le centriste16-Nov-08 2:33 
All public and protected methods are inherited, except the constructors.

Suppose the following:

public class A
{
    public A()
    {
    }
}

public class B : A
{
    public B(int i)
    {
    }
}

A a = new A(); // Compiles OK
B b1 = new B(5); // Compiles OK
B b2 = new B(); // Compile error: No overload for method 'B' takes '0' arguments


If B does not define an empty constructor, it does not inherit it. There is one subtle thing happening here the compile does not tell you. Since B's only constructor does not specify which base class constructor to call, it calls A's empty costructor silently.

Consider the following code:

public class A
{
    public A(string s)
    {
    }
}

public class B : A
{
    public B(int i)
    {
    }
}

B b = new B(5); // Compile error: No overload for method 'A' takes '0' arguments


Since B does not specify which constructor from A to call, the compiler tries to place a call to A's empty constructor, but it does not exists, hence the error.

The following code would work:

public class A
{
    public A(string s)
    {
    }
}

public class B : A
{
    public B(int i) : base(i.ToString())
    {
    }
}

B b = new B(5); // Compiles OK


So, in your case, the base class defines a constructor for serialization, but you class does not inherit it.
GeneralRe: Exception Constructor Pin
George_George16-Nov-08 2:47
George_George16-Nov-08 2:47 
GeneralRe: Exception Constructor Pin
Le centriste16-Nov-08 2:54
Le centriste16-Nov-08 2:54 
GeneralRe: Exception Constructor Pin
George_George16-Nov-08 2:56
George_George16-Nov-08 2:56 

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.