Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
C# 7 and .NET Core: Modern Cross-Platform Development

You're reading from   C# 7 and .NET Core: Modern Cross-Platform Development Create powerful cross-platform applications using C# 7, .NET Core, and Visual Studio 2017 or Visual Studio Code

Arrow left icon
Product type Paperback
Published in Mar 2017
Publisher
ISBN-13 9781787129559
Length 594 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (24) Chapters Close

C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Hello, C#! Welcome, .NET Core! FREE CHAPTER 2. Speaking C# 3. Controlling the Flow, Converting Types, and Handling Exceptions 4. Using .NET Standard Types 5. Debugging, Monitoring, and Testing 6. Building Your Own Types with Object-Oriented Programming 7. Implementing Interfaces and Inheriting Classes 8. Working with Databases Using the Entity Framework Core 9. Querying and Manipulating Data with LINQ 10. Working with Files, Streams, and Serialization 11. Protecting Your Data 12. Improving Performance and Scalability with Multitasking 13. Building Universal Windows Platform Apps Using XAML 14. Building Web Applications Using ASP.NET Core MVC 15. Building Mobile Apps Using Xamarin.Forms and ASP.NET Core Web API 16. Packaging and Deploying Your Code Cross-Platform Answers to the Test Your Knowledge Questions

Chapter 7 - Implementing Interfaces and Inheriting Classes


  1. What is a delegate?

    • A delegate is a type-safe method reference. It can be used to execute any method with a matching signature.

  2. What is an event?

    • An event is a field that is a delegate having the event keyword applied. The keyword ensures that only += and -= are used; this safely combines multiple delegates without replacing any existing event handlers.

  3. How is a base class and a derived class related?

    • A derived class (or subclass) is a class that inherits from a base class (or superclass).

  4. What is the difference between the is and as operators?

    • The is operator returns true if an object can be cast to the type. The as operator returns a reference if an object can be cast to the type; otherwise, it returns null.

  5. Which keyword is used to prevent a class from being derived from, or a method from being overridden?

            sealed 
    
  6. Which keyword is used to prevent a class from being instantiated with the new keyword?

            abstract 
    
  7. Which keyword is used to allow a member to be overridden?

            virtual 
    
  8. What's the difference between a destructor and a deconstructor?

    • A destructor, also known as a finalizer, must be used to release resources owned by the object. A deconstructor is a new feature of C# 7 that allows a complex object to be broken down into smaller parts.

  9. What are the signatures of the constructors that all exceptions should have?

    • The following are the signatures of the constructors that all exceptions should have:

      • A constructor with no parameters

      • A constructor with a string parameter usually named message

      • A constructor with a string parameter, usually named message, and an Exception parameter usually named innerException

  10. What is an extension method and how do you define one?

    • An extension method is a compiler trick that makes a static method of a static class appear to be one of the members of a type. You define which type you want to extend by prefixing the type with this.

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 $15.99/month. Cancel anytime
Visually different images