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());
                }
            }
  • 相关阅读:
    第二周:Python3的内存管理
    第一周:JDBC中批量插入数据问题
    PyTorch对ResNet网络的实现解析
    三素数定理的证明及其方法(二)
    三素数定理的证明及其方法(一)
    羊车门问题
    对python语言学习的期待
    My first page
    windowns右键notepad++ 打开文件
    Idea里新建类的快捷键
  • 原文地址:https://www.cnblogs.com/Fred1987/p/14469142.html
Copyright © 2011-2022 走看看