1. 程式人生 > >Visual studio 2019 preview & C# 8 initial experience

Visual studio 2019 preview & C# 8 initial experience

object style 分享圖片 otn ros .net reference mage span

Visual studio 2019 preview & C# 8 initial experience

技術分享圖片

技術分享圖片

?

技術分享圖片

?

技術分享圖片

?

using System;

using static System.Console;

namespace ConsoleApp2

{

class Program

{

static void Main(string[] args)

{

string s = null;

WriteLine(s.ToString());

WriteLine($"The first letter of {s} is {s[0]}");

}

}

}

技術分享圖片

?

<Project Sdk="Microsoft.NET.Sdk">

?

<PropertyGroup>

<OutputType>Exe</OutputType>

<TargetFramework>netcoreapp3.0</TargetFramework>

<ApplicationIcon />

<StartupObject />

<AssemblyName>ConsoleApp1</AssemblyName>

<RootNamespace>ConsoleApp1</RootNamespace>

<LangVersion>8.0</LangVersion>

<NullableReferenceTypes>true</NullableReferenceTypes>

</PropertyGroup>

?

?

技術分享圖片

?

技術分享圖片

?

技術分享圖片

?

using System;

using static System.Console;

namespace ConsoleApp2

{

class Program

{

static void Main(string[] args)

{

string? s = null;

?

WriteLine($"The first letter of {s}is {s?[0] ?? ‘?‘}");

}

}

}

?

Visual studio 2019 preview & C# 8 initial experience