Beginning C# 7 Programming with Visual Studio 2017 by Perkins Benjamin & Hammer Jacob Vibe & Reid Jon D
Author:Perkins, Benjamin & Hammer, Jacob Vibe & Reid, Jon D. [Perkins, Benjamin]
Language: eng
Format: epub
ISBN: 9781119458661
Publisher: Wiley
Published: 2018-03-19T16:00:00+00:00
13.7 How would you ensure that the extension method in Question 4 was available to your client code?
13.8 Rewrite the ToAcronym() method shown here as a single statement. The code should ensure that strings including multiple spaces between words do not cause errors. Hint: You will require the ?: tertiary operator, the string.Aggregate<string, string>() extension method, and a lambda expression to achieve this.
Answers to the exercises can be found in Appendix.
WHAT YOU LEARNED IN THIS CHAPTER
TOPIC KEY CONCEPTS
Namespace qualification To avoid ambiguity in namespace qualification, you can use the : : operator to force the compiler to use aliases that you have created. You can also use the global namespace as an alias for the top‐level namespace.
Custom exceptions You can create your own exception classes by deriving from the root Exception class. This is helpful because it gives you greater control over catching specific exceptions, and allows you to customize the data that is contained in an exception in order to deal with it effectively.
Event handling Many classes expose events that are raised when certain triggers occur in their code. You can write handlers for these events to execute code at the point where they are raised. This two‐way communication is a great mechanism for responsive code, and prevents you from having to write what would otherwise be complex, convoluted code that might poll an object for changes.
Event definitions You can define your own event types, which involves creating a named event and a delegate type for any handlers for the event. You can use the standard delegate type with no return type and custom event arguments that derive from System.EventArgs to allow for multipurpose event handlers. You can also use the EventHandler and EventHandler<T> delegate types to define events with simpler code.
Anonymous methods Often, to make your code more readable, you can use an anonymous method instead of a full event handler method. This means defining the code to execute when an event is raised in‐line at the point where you add the event handler. You achieve this with the delegate keyword.
Attributes Occasionally, either because the framework you are using demands it or because you choose to, you will make use of attributes in your code. You can add attributes to classes, methods and other members using [AttributeName] syntax, and you can create your own attributes by deriving from System.Attribute . You can read attribute values through reflection.
Initializers You can use initializers to initialize an object or collection at the same time as creating it. Both types of initializers consist of a block of code surrounded by curly brackets. Object initializers allow you to set property values by providing a comma‐separated list of property name/value pairs. Collection initializers simply require a comma‐separated list of values. When you use an object initializer, you can also use a nondefault constructor.
Type inference The var keyword allows you to omit the type of a variable when you declare it. However, this is possible only if the type can be determined at compile time.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12571)
Hello! Python by Anthony Briggs(9916)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9796)
The Mikado Method by Ola Ellnestam Daniel Brolund(9779)
Dependency Injection in .NET by Mark Seemann(9340)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8298)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7076)
Microservices with Go by Alexander Shuiskov(6843)
Practical Design Patterns for Java Developers by Miroslav Wengner(6764)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6703)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6414)
Angular Projects - Third Edition by Aristeidis Bampakos(6108)
The Art of Crafting User Stories by The Art of Crafting User Stories(5638)
NetSuite for Consultants - Second Edition by Peter Ries(5570)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5375)
Kotlin in Action by Dmitry Jemerov(5063)
