zoukankan      html  css  js  c++  java
  • C# 8 using declarations

    The new feature is only available in C# 8 or greater,so add below statement in csproj file

    <LangVersion>8</LangVersion>

    <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <LangVersion>8</LangVersion>
        <ProjectGuid>{BE2A508B-D299-4882-961F-E5DDD76123EF}</ProjectGuid>
        <OutputType>Exe</OutputType>
        <RootNamespace>ConsoleApp1</RootNamespace>
        <AssemblyName>ConsoleApp1</AssemblyName>
        <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
        <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
        <Deterministic>true</Deterministic>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <LangVersion>8</LangVersion>
        <PlatformTarget>AnyCPU</PlatformTarget>
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>binDebug</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <LangVersion>8</LangVersion>
        <PlatformTarget>AnyCPU</PlatformTarget>
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>binRelease</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
    static void UsingDeclarations()
            {
                if(File.Exists("file.txt"))
                {
                    using var reader = File.OpenText("file.txt");
                    Console.WriteLine(reader.ReadToEnd());
                }
            }
  • 相关阅读:
    线性表3 数据结构和算法08
    线性表3 数据结构和算法08
    线性表的链式存储结构
    OD使用教程9 调试篇09|解密系列
    线性表
    线性表
    线性表
    OD使用教程9 调试篇09|解密系列
    验证中英文数字和下划线中划线
    formEl.submit is not a function的原因
  • 原文地址:https://www.cnblogs.com/Fred1987/p/14469142.html
Copyright © 2011-2022 走看看