Book Image

C# 6 and .NET Core 1.0

Book Image

C# 6 and .NET Core 1.0

Overview of this book

With the release of .NET Core 1.0, you can now create applications for Mac OS X and Linux, as well as Windows, using the development tools you know and love. C# 6 and .NET Core 1.0 has been divided into three high-impact sections to help start putting these new features to work. First, we'll run you through the basics of C#, as well as object-orient programming, before taking a quick tour through the latest features of C# 6 such as string interpolation for easier variable value output, exception filtering, and how to perform static class imports. We'll also cover both the full-feature, mature .NET Framework and the new, cross-platform .NET Core. After quickly taking you through C# and how .NET works, we'll dive into the internals of the .NET class libraries, covering topics such as performance, monitoring, debugging, internationalization, serialization, and encryption. We'll look at Entity Framework Core 1.0 and how to develop Code-First entity data models, as well as how to use LINQ to query and manipulate that data. The final section will demonstrate the major types of applications that you can build and deploy cross-device and cross-platform. In this section, we'll cover Universal Windows Platform (UWP) apps, web applications, and web services. Lastly, we'll help you build a complete application that 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 (25 chapters)
C# 6 and .NET Core 1.0
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 4 – Using Common .NET Types


  1. Does every assembly that you create have a reference to the mscorlib.dll assembly?

    No. Although by default every assembly will have an automatic reference to the mscorlib.dll assembly, there is a compiler flag that can prevent this. For details, visit:

    https://msdn.microsoft.com/en-us/library/fa13yay7.aspx

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

    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.

  3. When and why should you use the SecureString type?

    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

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

    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?

    The SortedList class uses less memory than SortedDictionary, SortedDictionary has faster insertion and removal operations for unsorted data. If the list is populated all at once from sorted data, SortedList is faster than SortedDictionary. For more discussion, visit:

    http://stackoverflow.com/questions/935621/whats-the-difference-between-sortedlist-and-sorteddictionary

  6. 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?

    The effort is not worth the pain for you or your users. Validating an e-mail address using official specification doesn't check whether that address actually exists or whether the person entering the address is its owner. For more discussion, visit:

    http://davidcel.is/posts/stop-validating-email-addresses-with-regex/

    http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address