zoukankan      html  css  js  c++  java
  • Develping Libraries With Cross Platform Tools跨平台工具开发库

    设定多个目标版本 How to Multitarge

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFrameworks>netstandard1.4;net40;net45</TargetFrameworks>
      </PropertyGroup>
    
      <!-- Need to conditionally bring in references for the .NET Framework 4.0 target -->
      <ItemGroup Condition="'$(TargetFramework)' == 'net40'">
        <Reference Include="System.Net" />
      </ItemGroup>
    
      <!-- Need to conditionally bring in references for the .NET Framework 4.5 target -->
      <ItemGroup Condition="'$(TargetFramework)' == 'net45'">
        <Reference Include="System.Net.Http" />
        <Reference Include="System.Threading.Tasks" />
      </ItemGroup>
    </Projecusing System;
    using System.Text.RegularExpressions;
    #if NET40
    // This only compiles for the .NET Framework 4 targets
    using System.Net;
    #else
     // This compiles for all other targets
    using System.Net.Http;
    using System.Threading.Tasks;
    #endif
    
    namespace MultitargetLib
    {
        public class Library
        {
    #if NET40
            private readonly WebClient _client = new WebClient();
            private readonly object _locker = new object();
    #else
            private readonly HttpClient _client = new HttpClient();
    #endif

    ......
    } }
  • 相关阅读:
    用SQL实现的一个自动排课机制
    如何读懂复杂的C声明
    Mingw32配置
    test
    HttpSession API
    java程序逻辑控制
    方法的定义及使用
    memcached 安装及集成(转)
    cookie和session的的区别以及使用示例?
    构造方法和普通方法的区别?
  • 原文地址:https://www.cnblogs.com/fmys/p/10207739.html
Copyright © 2011-2022 走看看