C# Tutorial 22 – Class Inheritance
Here we learn how to inherit from a Class and learn the difference between a “has a” relationship and an “is a” relationship. Visit my website at thebosscode…
Video Tutorial Rating: 4 / 5
Don’t forget to check out our other video tutorials or share this video with a friend.
10 responses to “C# Tutorial 22 – Class Inheritance”
Leave a Reply Cancel reply
Video Tutorials
Bringing you the best video tutorials for Photoshop, Illustrator, Fireworks, WordPress, CSS and others.
Video tutorial posted 09/02/15
Category: C# Tutorials
Tags: Class, Inheritance, Tutorial
Pages
Random Videos
Video Categories
- 3DS Max Tutorials (150)
- After Effects Tutorials (160)
- C# Tutorials (121)
- Colour (6)
- Crazy Effects (1)
- CSS Tutorials (120)
- Dreamweaver Tutorials (139)
- Excel Tutorials (127)
- Featured (10)
- Fireworks Tutorials (131)
- General Effects (9)
- HTML Tutorials (143)
- Illustration and Vector (1)
- Illustrator Tutorials (174)
- IMove Tutorials (119)
- Lightroom Tutorials (145)
- People and Faces (3)
- Photoshop Tutorials (169)
- Text Effects (7)
- Uncategorized (32)
- WordPress Tutorials (140)
Tags
VideoTutorials.co.uk
-
Videotutorials.co.uk offers the web's best Photoshop tutorials, Illustrator video guides, CSS and HTML tutorials and much more all in one place. With new videos being added every day, you can learn how to master software and code to give your images and website some great effects.
Our site has beginner, intermediate and advanced video tutorials of varying lengths so you can learn a new skill at your own speed and level. So whether you're a web designer, print designer or just wanting to edit some family photos, you can get to it quickly and easily using these free video guides. (more)
this is an old video and meant for new programmers, but you still should be
using best practices to teach good habits early on (i’m being picky).
instead of making global variables that have their own unique name, which
is a waste of a variable name, you should make all relevant variable names
the same, and use the “this” keyword to point to the global variable(s).
example:
class Car {
private int tankSize¹;
private int horsePower¹;
public Car(int tankSize², int horsePower²) {
this.tankSize¹ = tanksize²;
this.horsePower¹ = horsePower²;
}
}
Note that the degree numbers are just used to show how the variables are
being used. Also, you don’t need to give the variables a value in the base
class. They’ll be initialized and/or overridden by the constructor anyway,
so it’s a waste of memory.
Note: I’m not trying to rip your video apart, but rather help newbies out
for best practices right away. Happy coding! :)
First year in College at CS, but I do OOP in second year. I took an
optional paid course for C# which is ‘taught’ by an older student (year 4
or smth) therefore inexperienced.
Well, I’m pretty new to C# myself (about 2-3 months, at a facultative
course) and I feel that they’ve focused on totally wrong things so far and
that’s why I searched for an online tutorial. Thanks you for doing this. In
about 3 weeks I’m gonna have a practical exam and I feel really afraid of
it to be honest. I have close to no experience to OOP. I’ve done C/C++
mostly so far (no OOP), so this is a totally new thing for me.
Thanks for pointing all of these things out to me, though. You’ve been
giving me a lot of feedback in just a few days!
Yes, that’s correct. If I said something different, then good for you for
pointing it out! When I recorded this, I hadn’t coded in Java for quite
some time, so I may have forgotten the discrepancies between Java and C#.
Java can only inherit from one class at a time. That is, a class in java
can only extend one other class, but it can implement multiple interfaces
which is very different. I don’t know too much about c++, but I believe it
does allow multiple-inheritance.
I know, and that would have made the implementation a lot simpler; however,
since this is a tutorial series, I assume no prior knowledge of the
programming language and I have yet to discuss the “this” keyword yet, so
using it would/may have caused some confusion.
So, they’ve been teaching you C# for about 2-3 months and they have yet to
touch on OOP? Sounds to me like someone isn’t doing their job correctly.
Here you could’ve used ‘this’ word at 7:30 for even better usage. instead
of private int tankSizeActual, you could’ve named it tankSize and used in
the Car constructor: this.tankSize=tankSize;
Well, now that I think about it, my Computer Science course in high school
didn’t get to OOP for a few months, but any tests we had did not test us
over OOP. If the teacher hasn’t taught you OOP, they should not test you
over it.