| | |
have a problem with inheritance
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Oct 2008
Posts: 63
Reputation:
Solved Threads: 0
I built two different classes and I want that one class get inherit from another ,
but when I build Constructions Compiler throw me an Error.
I get to conclusion that i must use base function
so I build Constructor like this one :
public name_class:base()
my question what do I put between parentheses and if my syntax o.k and what is the right way to built such constructor
Thanks, sergey
but when I build Constructions Compiler throw me an Error.
I get to conclusion that i must use base function
so I build Constructor like this one :
public name_class:base()
my question what do I put between parentheses and if my syntax o.k and what is the right way to built such constructor
Thanks, sergey
•
•
Join Date: Oct 2008
Posts: 63
Reputation:
Solved Threads: 0
It's O.K. this thing I understand I mean syntax of building Constructors and call for Metgods of parents, I tried a couple things and here what I got :
public Name_of Chuld (type_of_variable name_of_it):base(name_of_this_variable_in_Parent)
and when I call for parent function :
base.Name_ofParentFunction();
are the other way of doing so, and how it will look like for calling Parent function that get's some variables from Main for example ?
Thanks Sergey
public Name_of Chuld (type_of_variable name_of_it):base(name_of_this_variable_in_Parent)
and when I call for parent function :
base.Name_ofParentFunction();
are the other way of doing so, and how it will look like for calling Parent function that get's some variables from Main for example ?
Thanks Sergey
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
OK but if you had
You would call this in your inherited with
C# Syntax (Toggle Plain Text)
class MyClass { private int myval =0; public MyClass (int value) { myval=value; } public int MyValue { return myval; } }
You would call this in your inherited with
C# Syntax (Toggle Plain Text)
public MyNewClass : MyClass { public int MyNewValue : base MyValue(1) { } }
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
![]() |
Similar Threads
- Problem with inheritance (C++)
- Ask a problem,about inheritance :) (C++)
- also having a problem with inheritance (C++)
- C++ BASICS ==> Pointers, Call by Reference/Value, Inheritance, Functions & Arrays (C++)
- C++ Beginner - #include recursion problem (C++)
- help with polymorphism and inheritance...getting null values (Java)
- Annoying problem with moving files (Windows NT / 2000 / XP)
Other Threads in the C# Forum
- Previous Thread: merging image
- Next Thread: Problem with keyboard control in C#
| Thread Tools | Search this Thread |
.net access algorithm animation array asp avltree bitmap box c# check checkbox client column combobox control conversion csharp database datagrid datagridview datagridviewcheckbox dataset datetime degrees directrobot display draganddrop drawing encryption enum excel file form format formatting formbox forms formupdate function gdi+ hash image input install java label leak linux list math mouseclick mp3 mysql namevaluepairs native networking operator packaging path photoshop picturebox pixelinversion post powerpacks print process programming radians regex remoting reporting richtextbox robot safari server sleep snooze socket sql statistics string table tables tcp text textbox thread time timer update usercontrol usercontrols validation visualstudio webbrowser wfa winforms wpf xml






