Book Image

C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition

Book Image

C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition

Overview of this book

If you want to build powerful cross-platform applications with C# 7 and .NET Core, then this book is for you. First, we’ll run you through the basics of C#, as well as object-oriented programming, before taking a quick tour through the latest features of C# 7 such as tuples, pattern matching, out variables, and so on. After quickly taking you through C# and how .NET works, we’ll dive into the .NET Standard 1.6 class libraries, covering topics such as performance, monitoring, debugging, serialization and encryption. The final section will demonstrate the major types of application that you can build and deploy cross-device and cross-platform. In this section, we’ll cover Universal Windows Platform (UWP) apps, web applications, mobile apps, and web services. Lastly, we’ll look at how you can package and deploy your applications so that they can be hosted on all of today’s most popular platforms, including Linux and Docker. By the end of the book, you’ll be armed with all the knowledge you need to build modern, cross-platform applications using C# and .NET Core.
Table of Contents (24 chapters)
C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Chapter 4 - Using .NET Standard Types


  1. What is the maximum number of characters that can be stored in a string?

    • The maximum size of a string variable is 2 GB or about 1 billion characters because each char variable uses 2 bytes due to the internal use of Unicode (UTF-16) encoding for characters.

  2. When and why should you use a SecureString?

    • The string type leaves text data in memory for too long and it's too visible. The SecureString type encrypts the text and ensures that the memory is released immediately. WPF's PasswordBox control stores the password as a SecureString variable, and when starting a new process, the Password parameter must be a SecureString variable. For more discussion, visit:

    • http://stackoverflow.com/questions/141203/when-would-i-need-a-securestring-in-net

  3. When is it appropriate to use a StringBuilder?

    • When concatenating more than about three string variables, you will use less memory and get improved performance using StringBuilder than using string.Concat method or the + operator.

  4. When should you use a LinkedList<T>?

    • Each item in a linked list has a reference to its previous and next siblings as well as the list itself so should be used when items need to be inserted and removed from positions in the list without actually moving the items in memory.

  5. When should you use a SortedDictionary variable rather than a SortedList variable?

  6. What is the ISO culture code for Welsh?

            cy-GB 
    
  7. What is the difference between localization, globalization, and internationalization?

    • Localization affects the user interface of your application. Localization is controlled by a neutral (language only) or specific (language and region) culture. You provide multiple language versions of text and other values. For example, the label of a text box might be First name in English, and Prénom in French.

    • Globalization affects the data of your application. Globalization is controlled by a specific (language and region) culture, for example, en-GB for British English, or fr-CA for Canadian French. The culture must be specific because a decimal value formatted as currency must know to use Canadian dollars instead of French Euros.

    • Internationalization is the combination of localization and globalization.

  8. In a regular expression, what does $ mean?

    •  $ represents the end of the input.

  9. In a regular expression, how would you represent digits?

    •  \d+

    • [0-9]+

  10. Why should you not use the official standard for e-mail addresses to create a regular expression to validate a user's e-mail address?