| | |
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#
Views: 481 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file form format forms ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics string table textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






