Chapter 8 – Using Common .NET Standard Types

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

Answer: 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.

  1. When and why should you use a SecureString type?

Answer: The string type leaves text data in the 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: ...

Get C# 7.1 and .NET Core 2.0 – Modern Cross-Platform Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.