| | |
have a problem with inheritance
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
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 array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom cyclethruopenforms data database datagrid datagridview dataset date/time datetime degrees development dll draganddrop drawing encryption enum event excel file finalyearproject form format forms function gdi+ getoutlookcontactusinfcsvfile globalization httpwebrequest image index input install installer java label list listbox mandelbrot math mono mouseclick mysql operator panel path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox save server silverlight sleep socket sql sql-server statistics stream string table text textbox thread time timer timespan update usercontrol users validate validation visualstudio webbrowser wia windows winforms wpf xml






