C# Tutorial 7 Inheritance Polymorphism

[ad_1]
Get the Code Here :
Best C# Book :
Support me on Patreon :

If you can’t donate a Like is Greatly Appreciated 🙂

In this part of my C# Tutorial we learn about Inheritance, Aggregations, Virtual, Override, Inner Classes, New, Base, Polymorphism and much more.

For best results take notes on the cheat sheet provided above as you watch and leave any questions you have.

Thank you to Patreon supporters like the following for helping me make this video

facebook.com/cottageindustriesbuild/
jaryd remillard : instagram: @distant_admiration
bugreplay.com
@kyleaisho
@thetwistedhat
vjFaLk
jaryd remillard :


Posted

in

by

Tags:

Comments

48 responses to “C# Tutorial 7 Inheritance Polymorphism”

  1. Kenneth Hahn Winther Avatar

    Thank you for a great video(s).
    I'm getting a recursive loop on the instance of animal id ( protected AnimalIDInfo animalIDInfo = new AnimalIDInfo();)
    I have no idea why.

  2. Abrar Iqbal Avatar

    The best tutorials to learn C#.

  3. Pavel Franta Avatar

    Thank you, Derek, for your videos, guys like you CAN change or significantly help with changing others careers or growing knowledge of programming. Guys like you started off new era of independent home learning and i am very grateful for your videos and your effort to help and teach other guys how to write a code. Thank you very much, Pavel

  4. Yasser Osama Avatar

    so derek , why did you use new when you wanted to override MakeSound , and then used override later ? what's the difference between them ?

  5. Sticko Avatar

    When would i use the "new" keyword instead of overriding a method?

  6. element74 Avatar

    10:01 What is it called when you use curly braces after calling the constructor while instantiating, such as Dog grover = new Dog(){}. I didn't know you could put methods in there as if it were like a property, but different from a property because you use a semicolon after the curly braces. I don't believe you ever mentioned what this is called except for the fact that you can instantiate stuff in this manner.

    edit: I guess it is a property right? but you put a semicolon at the end because you made a statement with the = sign. Or maybe you are defining a new constructor right there. Is the latter correct? No, it is more like how you initialize an array with the curly braces, except with methods and you cant remove the 'new' operator.

  7. element74 Avatar

    10:57 Hi Derek, there is a problem with what you were trying to do with the 'protected' field called sound. You specifically stated you were trying to directly change the field sound because it was protected. I know your intentions were to demonstrate the purpose of the access modifier 'protected'. But you indirectly changed it by using the property Sound. So even if you labeled your field private, it would still work because you indirectly changed it.

    I think you should really fix this, or at least make an annotation of what you meant do here. Also, you would not be able to use grover.sound inside class Program because Program is not a subclass of Animal.

    The definition for 'protected' is found in 3 different pages on MSDN:
    https://msdn.microsoft.com/en-us/library/bcd5672a.aspx
    https://msdn.microsoft.com/en-us/library/ba0a1yw2.aspx
    https://msdn.microsoft.com/en-us/library/ms173121.aspx

    p.s. I'm still a noob at programming, so that's why i went through long lengths to try to understand every detail you explain.

  8. NovakGoran Avatar

    at 11:30 you changed the property Sound and not the 'sound' attribute itself. So if the 'sound' attribute was labeled as private, you would still be able to change Sound ( the property ). Am I missing or misunderstanding something here or is there actually no difference in this case?

  9. heath bm Avatar

    Hey Derek, Nice video, but line 65 doesn't make sense I think. if any chars in the value are not equal to digits, set name = "No name" ELSE set name = value (IF THERE ARE NUMBERS)

  10. Michał Szopa Avatar

    Thanks man! Great tutorials ! 🙂

  11. TheDude61636 Avatar

    i really love what you are doing i'm following your videos, but i have one little small issue
    18:03
    you used a condition if (condition) {return true} else return false
    it does the job but i really think this should be just return condition
    it does run and it does the same thing but why do it your way?
    unless you're just trying to show what the condition is doing but eh

  12. Rick Morty Avatar

    Thank you very much for the pretty much comprehensive tutorials, Derek. By the way, there's an error in the Animal.cs file: the setter of the Name property shouldn't have the "!", so it should look like this "if (value.Any(char.IsDigit))" else animals' names will be "No name".

  13. Haroon Ramay Avatar

    Hi. So I was practicing C# using your tutorial videos. They are quite amazing may I add.
    But I was having trouble at "if (!value.Any(char.IsDigit))" inside Class Animal where setter and getter are defined for Name. When I run your program it prints out No Name meaning this if statement is triggered.
    However, this did not happen for the code in previous tutorial. Afraid I might have messed something up while following this video I copied the code transcript that you have provided and am getting the same result. If I remove the negation from the if statement the code runs fine and gives the expected output. Could please help clarify this problem. Thanks.

  14. Maxim Shevchenko Avatar

    Awesome! Superclear and consistent!

  15. Alpine Mobile Avatar

    At https://youtu.be/ZzVxgJmLAsE?t=686 I have changed "protected string sound;" to "private string sound;" and I see no error. The method still works even if sound is not labeled as protected. Is that ok?

  16. malek yasser Avatar

    thank you for your videos .can you please do a tutorial about J2EE !!!!

  17. kntemplar Avatar

    I would like to see a Haxe tutorial since it has a cross compiler that can produce source code in C++, C#, Java and others. Thank you.

  18. Dime Markoski Avatar

    Derek, please make toutorials for .net c#?

  19. Madolite Avatar

    Can't wait to see more. 🙂

  20. GamePlayer6464 Avatar

    did you install complete visual studio ?

  21. arjaa ansari Avatar

    please also upload more tutorial about "data binding".. "Data set"."Data Adapter"…etc

  22. tinomutendaishe msakwa Avatar

    Hey Mr Banas. Been wanting to ask you for a while now how you learn all these languages and how long it takes you to pick one up. Do you use books, online PDFs, articles, videos, etc. And also, if i wanted to really understand a language so i'm comfortable in applying it fully, what is the best way to memorise as much syntax as i can, and what to use it for.

    Thanks

  23. NP Avatar

    Very good video 🙂 Will you cover some "what's happening under the hood" things for arrays, stacks, linked lists etc too or will you only scratch the surface of those topics and make a basic guide?

    I personally would appreciate if your cover async programming with the task.parallel library but it's a more advanced topic so I can understand if you don't want to cover it in this videos.

  24. Vinay.P Avatar

    Just another great tutorial 🙂 Thank you Derek. Can you please tell me which books and video tutorials do I need to see for absolute beginners into coding. I need to have very strong fundamentals.

  25. aVhD Avatar

    Thanks for the Amazing C# Tutorial. How about a Computer Engineering Tutorial? Fixing, repairing Computers, seeing you do it teaching hands on would be great.

  26. LEE YOO Avatar

    Would you also make a video about attributes in C#?

  27. Veselin Popov Avatar

    Hi Derek! I want to thank you for the great tutorials! I needed to introduce myself with C++ for my student’s job and your “C++ in one video” helped me a lot to become an overview of the language (I had little Java experience). Then I decided to buy the book, that you suggested under the video – “C++ Primer Plus (Developer’s library)” and I have to say that it is extremely well written! I reached the STL Chapter and I have almost no problems with the understanding and developing of a C++ code. However, now I track your Java tutorials, that are enormously helpful and I’m considering to buy the “Head First Java” book as first and than maybe “Effective Java” and “Head First Design Patterns”. So, now to my two questions:
    1. Do you think that I need to buy these books after I have accomplished your tutorials (a lot of stuff will be repeated)?
    2. Are you always reading these books as a preparation for your video series on the particular language? And if not, how many programming books have you read? How many programming books should one developer read to be a good developer? Thank you a lot! (-:

  28. João Alves Avatar

    Excellent videos !!!
    I don't understand what is the keyword "struct".
    The book in description says: "The concept of a structure is also formalized under the CTS. If you have a C background, you should
    be pleased to know that these user-defined types (UDTs) have survived in the world of .NET (although
    they behave a bit differently under the hood). Simply put, a structure can be thought of as a
    lightweight class type having value-based semantics. ".

    Can you explain again ?

    Thanks

  29. orthodox-4-ever Avatar

    Just another great tutorial 🙂

  30. wtf2925 Avatar

    Do you plan to cover XAML as a part of the C# language series?

  31. Joey Vico Avatar

    Hi Derek, I told you the other day that you looked a lot younger than your voice tells which apparently has surprised many of your viewers. Just want to say you are being a great tutor and your videos are awesome. Also, just wondering, how come you aren't into linux stuff? Kind regards

  32. mark adel Avatar

    Why do you always do classes about animals?

  33. Your Pal Nurav Avatar

    What software do you use to record your videos on Windows OS. I've tried really hard to search for a software that zooms and pans while recording but Google search always directs me to Camtasia.

  34. Cătălin George Feștilă Avatar

    any examples and tutorials about C# classes are great because few template come into area of learning C# classes , so you can make more even using Unity 3D framework. thank's

  35. Jeff Merlin Avatar

    Thanks again, Derek. This is really great. Unfortunately you did it again, at 04:40 the "else" is missing and now it's also missing in the Code & Transcript. What you actually say is correct of course. You say "otherwise", and maybe that is why you forget to type "else". (I said it, why type it?) 😉 The result is that if you name your Animal "4me", it will actually get that name… For a nanosecond or two it will be "No Name", but that doesn't last long due to the missing else. A trap for young players… 🙂

  36. El Pepperinos Avatar

    If i don't put protected in front of AnimalIDInfo will it give an error?

  37. PushMyCarr Avatar

    Thank you for the video Derek!!
    I can' believe that my dream of getting into C# and game development is actually happening!
    I can't wait for the next part!

  38. Ilya Zhidkov Avatar

    Great as always! Cannot wait for the next part!!

  39. ebenezer popoola Avatar

    Hi Derek, nice videos.it has helped a lot. please, to pick up a role as a junior software developer (c#) what can be done?I have used mvc for a windows form application and two asp.net website, what more is needed?

  40. Damian Kucharski Avatar

    Have you maybe in mind making ASP.NET tutorial? 🙂

  41. NextLevelNoob Avatar

    Thank you Derek, your work is greatly appreciated.

  42. Corey Norris Avatar

    Are you going to cover topics like logging and/or unit tests?

  43. CoolUnknown Avatar

    Hey Derek, do you think C++ is still viable or should I stick to C# which I already know?

  44. wizkid2000 Avatar

    I actually develop in c# all the time. It is my favorite programing language. Even though I know all this stuff I still enjoy watching these tutorials.

  45. Abdulnaser Sheikh Avatar

    Mr. Derek when you are making these series please use mathematical equations in them.For example, make a method that solves the Pythagorean theorem. A^2 + B^2 = c^2. This would help us learn to use mathematical equations. Thank you for your time.

  46. fera fera Avatar

    gold
    but pleaaaaase no more than 20 minutes
    too much informations

  47. Abdulnaser Sheikh Avatar

    Mr. Derek do you use the c language?

Leave a Reply

Your email address will not be published. Required fields are marked *