Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
class Base
   {
       int BAx;
       int BAy;
       public Base(int _x, int _y)
       {
           BAx = _x;
           BAy = _y;
       }
   }
   class Child : Base
   {
       int CHx;
       int CHy;
       public Child(int _x, int _y)
           : base(0, 1) // i do not get Error when the argument passed in base constructor is static, but if i change argument to dynamic like this 
//public Child(int _x, int _y) : base(int D,int E) i get compilation error
       {
           CHx = _x;
           CHy = _y;
       }
   }
   class Program
   {
       static void Main(string[] args)
       {
       }
   }
Posted
Comments
Sergey Alexandrovich Kryukov 26-Feb-13 19:02pm    
What dynamic variable, what error, for goodness sake?
What do you mean "dynamic"?
—SA

1 solution

Method argument cannot be "static" in principle. The term "static" does not mean "not dynamic" it means "not instance" for members and "having no instance members" for a type. You have nothing static in your code (except static Main) which is irrelevant. The question as is makes no sense at all.

If you have compilation error with the line public Child(int _x, int _y) : base(int D,int E), this is only because D and E are not declared. Of course, how else? There is nothing about "static" or "dynamic" here; and your understanding of these terms is totally incorrect. Please see also my comment to the question.

For some basic education on this simple matter, please see these discussions:
What makes static methods accessible?[^],
C# windows base this key word related and its uses in the application[^].

—SA
 
Share this answer
 
Comments
Anderso0on 26-Feb-13 19:22pm    
i mean dynamic , static (Variable value) & (constant value)
Sergey Alexandrovich Kryukov 26-Feb-13 19:27pm    
I mean nothing! I already explained everything. If you still have a problem with compilation, go use "Improve question" and provide some code which does not compile.
—SA
Sergey Alexandrovich Kryukov 26-Feb-13 19:33pm    
Please understand what I'm going to say right. I looked through few of your most recent questions and see just one pattern: it looks you never learn any lessons from answers. Not only you never accept good answers, it even makes the impression that you don't read them or don't understand. Please forgive me if I'm wrong in something, but it makes it hard to make a decision to help you. What's wrong? Do you really fail to understand, or what?
—SA
Anderso0on 26-Feb-13 19:28pm    
ok , thank you
Anderso0on 26-Feb-13 19:40pm    
really i do not understand what is problem in my code if i write this statment
public Child(int _x, int _y) : base(int D,int E)
and i dont understand your explanation :( :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900