Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
C# 7.1 and .NET Core 2.0 ??? Modern Cross-Platform Development

You're reading from   C# 7.1 and .NET Core 2.0 ??? Modern Cross-Platform Development Create powerful applications with .NET Standard 2.0, ASP.NET Core 2.0, and Entity Framework Core 2.0, using Visual Studio 2017 or Visual Studio Code

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher
ISBN-13 9781788398077
Length 800 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Mark J. Price Mark J. Price
Author Profile Icon Mark J. Price
Mark J. Price
Arrow right icon
View More author details
Toc

Table of Contents (24) Chapters Close

Preface 1. Hello, C#! Welcome, .NET Core! FREE CHAPTER 2. Part 1, C# 7.1
3. Speaking C# 4. Controlling the Flow and Converting Types 5. Writing, Debugging, and Testing Functions 6. Building Your Own Types with Object-Oriented Programming 7. Implementing Interfaces and Inheriting Classes 8. Part 2 – .NET Core 2.0 and .NET Standard 2.0
9. Understanding and Packaging .NET Standard Types 10. Using Common .NET Standard Types 11. Working with Files, Streams, and Serialization 12. Protecting Your Data and Applications 13. Working with Databases Using Entity Framework Core 14. Querying and Manipulating Data Using LINQ 15. Improving Performance and Scalability Using Multitasking 16. Part 3 – App Models
17. Building Web Sites Using ASP.NET Core Razor Pages 18. Building Web Sites Using ASP.NET Core MVC 19. Building Web Services and Applications Using ASP.NET Core 20. Building Windows Apps Using XAML and Fluent Design 21. Building Mobile Apps Using XAML and Xamarin.Forms 22. Summary 23. Answers to the Test Your Knowledge Questions

Inheriting from classes


The Person type we created earlier is implicitly derived (inherited) from System.Object. Now, we will create a new class that inherits from Person.

Add a new class named Employee.cs to the PacktLibrary project.

Modify its code as shown in the following code:

using System; 
 
namespace Packt.CS7 
{ 
   public class Employee : Person 
   { 
   } 
}

Add statements to the Main method to create an instance of the Employee class:

Employee e1 = new Employee  
{ 
   Name = "John Jones",  
   DateOfBirth = new DateTime(1990, 7, 28)  
};
e1.WriteToConsole(); 

Run the console application and view the output:

John Jones was born on Saturday, 28 July 1990

Note that the Employee class has inherited all the members of Person.

Extending classes

Now, we will add some employee-specific members to extend the class.

In the Employee class, add the following code to define two properties:

public string EmployeeCode { get; set; } 
public DateTime HireDate { get; set; } 

Back in the Main method, add...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime