Название: Professional C# 6 and .NET Core 1.0
Автор: Christian Nagel
Издательство: John Wiley & Sons Limited
Жанр: Зарубежная образовательная литература
isbn: 9781119096634
isbn:
In C# 5
In C# 6
The nameof operator is covered in Chapter 8, “Operators and Casts.”
Null Propagation Operator
The null propagation operator simplifies null checks:
In C# 5
In C# 6
The new syntax also has an advantage for firing events:
In C# 5
In C# 6
The null propagation operator is covered in Chapter 8.
String Interpolation
The string interpolation removes calls to string.Format. Instead of using numbered format placeholders in the string, the placeholders can include expressions:
In C# 5
In C# 6
The C# 6 sample is reduced that much compared to the C# 5 syntax because it uses not only string interpolation but also an expression-bodied method.
String interpolation can also use string formats and get special features on assigning it to a FormattableString. String interpolation is covered in Chapter 10, “Strings and Regular Expressions.”
Dictionary Initializers
Dictionaries can now be initialized with a dictionary initializer – similar to the collection initializer.
In C# 5
In C# 6
Dictionary initializers are covered in Chapter 11, “Collections.”
Exception Filters
Exception filters allow you to filter exceptions before catching them.
In C# 5
In C# 6
A big advantage of the new syntax is not only that it reduces the code length but also that the stack trace is not changed – which happens with the C# 5 variant. Exception filters are covered in Chapter 14, “Errors and Exceptions.”
Await in Catch
await can now be used in the catch clause. C# 5 required a workaround.
In C# 5
In C# 6
This feature doesn’t need an enhancement of the C# syntax; it’s functionality that’s working now. This enhancement required a lot of investment from Microsoft to make it work, but that really doesn’t matter to you using this platform. For you, it means less code is needed – just compare the two versions.
NOTE The new C# 6 language features are covered in the mentioned chapters, and in all chapters of this book the new C# syntax is used.
Windows 8 introduced a new programming API, the Windows Runtime. Applications using the Windows Runtime could be made available via the Microsoft Store and were known with many different names. It started with Metro apps or Metro style apps, and they are also known as Modern apps, Windows Store apps (although they can also be installed with PowerShell scripts without using the store), and Universal apps. Probably there are some names I missed. Nowadays, these are just Windows apps, running on the Universal Windows Platform (UWP).
The idea of these apps was to allow end users to find them easily via the Microsoft store and to offer a touch-friendly environment, a modern user interface that looks nice and smooth and allows fluid interactions, and apps that can be trusted. More than that, the users who already know the Windows user interfaces should be attracted to using the new environment.
The first version of the design guidelines was very restrictive and had some flaws. How can I search for stuff in the app? Many users didn’t find the charms bar on the right side, and found out it allowed searching in many apps. Windows 8.1 moved the search to a search box directly on the desktop. Also, users often didn’t find the app bar located at the top or bottom if they didn’t perform a touch gesture from top to bottom or bottom to top.
Windows 10 made the design much more open. You can use the things that are useful for your apps and can decide on the user interface as it best matches your users and apps. Of course, it’s still best to create a nice looking, smooth, and fluid design. It’s better for having users happily interacting with the app, and they should not have a hard time finding out how things can be done.
The new Windows Runtime, Windows Runtime 3.0, steps on the predecessor versions to define an XAML user interface, implements an application lifecycle, and allows background functionality, sharing of data between applications, and more. Indeed, the new version of the runtime offers more features in all the areas.
Windows apps now make use of .NET Core. You can use the same .NET libraries available via NuGet packages with Windows apps. Finally, native code gets compiled for a faster app startup and less memory consumption.
What might be even more important than the additional features offered is the universality that’s now available. The first update of Visual Studio 2013 included a new project type for Windows 8 apps: Universal apps. Here, Universal apps have been done with three projects: one project for the Windows app, one project for the Windows phone app, and a shared code project. It was possible to even share XAML code between these platforms. The new Universal project template consists of one project. You can use the same binary not only for Windows and Windows Phone, but also for the Xbox, Internet of Things (IoT) devices, the HoloLens, and more. Of course, these different platforms offer features that are not available everywhere, but using this differing feature you can still create one binary image that runs on every Windows 10 device.
.NET Core runs on Windows, Linux, and Mac operating systems. You can create and build your programs on any of these operating systems using Visual Studio Code (https://code.visualstudio.com). The best developer tool to use, and the tool used СКАЧАТЬ