.NET6 全局using 帮你减少代码量

  1. .NET6默认开启全局using
  2. 具体配置如下
<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<OutputType>Exe</OutputType>
		<TargetFramework>net6.0</TargetFramework>
		<!--开启全局using-->
		<ImplicitUsings>enable</ImplicitUsings>
		<Nullable>enable</Nullable>
	</PropertyGroup>

</Project>

  1. 包含的命名空间如下
  • using System;
  • using System.IO;
  • using System.Collections.Generic;
  • using System.Linq;
  • using System.Net.Http;
  • using System.Threading;
  • using System.Threading.Tasks;
  1. 添加自定义命名空间方法
<ItemGroup>
  <Using Include="My.Awesome.Namespace" />
</ItemGroup>
  1. 示例地址:https://github.com/huzuohuyou/DotNet6-Examples.git
posted @ 2022-05-19 16:51  喜爱糖葫芦  阅读(366)  评论(0编辑  收藏  举报