小编Ron*_*ano的帖子

如果将a与á进行比较,我怎么能得到真假?

我正在研究string.Normalize()method,我认为如果它们使用不同的unicode,它可用于比较字符串相等性。

到目前为止,这是我所做的。这string.Equals()不是我应该在这里使用的吗?

        string stra = "á";
        string straNorm = stra.Normalize();
        string strFormC = stra.Normalize(NormalizationForm.FormC);
        string strFormD = stra.Normalize(NormalizationForm.FormD);
        string strFormKC = stra.Normalize(NormalizationForm.FormKC);
        string strFormKD = stra.Normalize(NormalizationForm.FormKD);
        Console.WriteLine("norm {0}",straNorm);
        Console.WriteLine("C {0}", strFormC);
        Console.WriteLine("D {0}", strFormD);
        Console.WriteLine("KC {0}", strFormKC);
        Console.WriteLine("KD {0}", strFormKD);

        Console.WriteLine("a".Equals(stra)); //false
        Console.WriteLine("a".Equals(straNorm)); //false
        Console.WriteLine("a".Equals(stra.Normalize())); //false
        Console.WriteLine("a".Equals(strFormC)); //false
        Console.WriteLine("a".Equals(strFormKC)); //false
        Console.WriteLine("a".Equals(strFormKD)); //false
Run Code Online (Sandbox Code Playgroud)

c# string

6
推荐指数
2
解决办法
132
查看次数

Azure 构建管道 NuGet 还原错误 NETSDK1045

我通过 Visual Studio 2019 创建了一个 Azure CI 管道。项目目标框架是 .net core 3.1。但是,在 NuGet 还原期间它会失败。我的计算机上安装了 .Net Core 2.2.2017 和 3.1.101,我的 Visual Studio 2019 社区版本是 16.4。我的环境变量路径已经到位。

我还尝试手动创建一个使用 .net core 3.1 LTS 堆栈的应用服务,但我仍然遇到相同的错误。

    ##[error]The nuget command failed with exit code(1) and error(C:\Program Files\dotnet\sdk\2.2.110\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5):

    error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1.  Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.1. 

Run Code Online (Sandbox Code Playgroud)

这是 Visual Studio 生成的 YAML 文件

pool:
  name: …
Run Code Online (Sandbox Code Playgroud)

c# azure .net-core asp.net-core

5
推荐指数
1
解决办法
2810
查看次数

Enable CORS in Minimal API

I have this code from Microsoft docs minimal apis CORS, when I run it I don't understand why the endpoints returns 200 OK when the CORS is enabled.

What should be the expected result when the endpoints are consumed?


const string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddCors(options =>
{
    options.AddPolicy(name: MyAllowSpecificOrigins,
                      builder =>
                      {
                          builder.WithOrigins("http://example.com",
                                              "http://www.contoso.com");
                      });

});

var app = builder.Build();
app.UseCors();

app.MapGet("/cors", [EnableCors(MyAllowSpecificOrigins)] () =>
                           "This endpoint allows cross origin requests!");
app.MapGet("/cors2", () => "This …
Run Code Online (Sandbox Code Playgroud)

.net c# .net-6.0

5
推荐指数
0
解决办法
1864
查看次数

为什么 Observable.create() 中的 setInterval() 继续运行?

我正在研究 rxjs Observables,但我不明白为什么 Observable.create 中的 setInterval 仍在运行,即使我已经取消订阅该 observable 对象。Observable 是异步的吗?应该什么时候停?

我有这个代码供参考:

var cancellableObserver = Observable.create((observer:any)=>{
try {
    observer.next("anyeong")
    observer.next("ande")
    console.log("logged once")
    setInterval(()=>{
        //this code block will keep running for every 2secs
        observer.next("eotteokke") //but this line will stop after unsubscribe
        console.log("will log every 2secs")
    },2000)
} catch (err) {
    observer.error(err);

}});

var cancellableSubscription = cancellableObserver.subscribe(
(x:any) =>addItem(x),
(err:any) =>addItem(err),
() => addItem("cancellable completed"));

setTimeout(() => {cancellableSubscription.unsubscribe();console.log("mary");}, 6001);
Run Code Online (Sandbox Code Playgroud)

javascript node.js rxjs typescript

2
推荐指数
1
解决办法
580
查看次数

为什么接受实现私有接口方法?

我正在研究接口,并遇到了一些奇怪的接口问题,其中的规则是我们必须实现公共接口方法。但是在这个例子中没有。

我尝试了从经验中学到的知识,发现的答案确实违反了规则。

    public interface DropV1
    {
        void Ship();
    }

    public interface DropV2
    {
        void Ship();
    }
    //accepted by the editor
    class DropShipping : DropV1, DropV2
    {
        void DropV1.Ship() { }
        void DropV2.Ship() { }

    }
Run Code Online (Sandbox Code Playgroud)

我原以为10亿%的实施将是:

public void DropV1.Ship()
public void DropV2.Ship()
Run Code Online (Sandbox Code Playgroud)

为什么会这样呢?

c# interface

1
推荐指数
1
解决办法
69
查看次数

ng build --prod 无法在 Azure CICD 管道中工作

我正在 Azure 中设置应用程序 CI/CD,但我不明白为什么它在构建过程中仍然失败。

这是我的 yaml

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '8.x'
  displayName: 'Install Node.js'

- script: |
    npm install
  displayName: 'npm install'

- script: |
    npm uninstall -g angular-cli
    npm cache clean or npm cache verify #(if npm > 5)
    npm install -g @angular/cli@7.1.4
  displayName: 'npm install @angular/cli'

- script: |
    ng build --prod
  displayName: 'npm build'
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '/src/app/dist/my-app'
    includeRootFolder: true
    archiveType: 'zip'
    archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true
Run Code Online (Sandbox Code Playgroud)

我以为是 …

azure-devops angular

1
推荐指数
1
解决办法
4510
查看次数

如何在 Azure DevOps 中使部分成功的阶段变为失败?

我正在发布管道上运行纽曼测试,但是当测试出错时,它只是将该阶段标记为部分成功,但我想让它无法触发自动重新部署触发器。这可能吗?

在此输入图像描述

azure azure-devops azure-pipelines

1
推荐指数
1
解决办法
6507
查看次数

如何使Azure Pipelines yaml触发特定项目的分支?

我在 Github 上有这个项目存储库,并且该存储库中有很多项目。

所以在我的场景中是这样的。

api-build-pipeline 项目-1:触发分支-1 ui-build-pipiline 项目-2:触发分支-1

因此,如果我只对project-1 有更新,则不应触发project-2,但如果它们的触发器是同一分支,我不知道该怎么做。

我想要像这样的触发器触发器:-branch-1 ..project-1

那可能吗?如果可能的话,我不希望他们使用不同的分支。

devops azure-devops

1
推荐指数
1
解决办法
1万
查看次数

为什么 BinaryReader.ReadDecimal() 返回错误值?

我将数据类型值存储到文件中然后使用它,但得到了错误的结果。我需要做什么才能得到正确的结果?

        BinaryWriter bw = new BinaryWriter(file.OpenWrite());
        string str = "Lalisa";
        int num = 10;
        decimal dec = 2;
        bw.Write(str);
        bw.Write(num);
        bw.Write(dec);
        bw.Close();

        BinaryReader br = new BinaryReader(file.OpenRead());
        Console.WriteLine(br.ReadString()); 
        Console.WriteLine(br.ReadInt16());
        Console.WriteLine(br.ReadDecimal());
        br.Close();

        /*
         output:
         Lalisa
         10
         131072
         */
Run Code Online (Sandbox Code Playgroud)

写入器输出

作者制作的文件

注意* 我正在使用 FileInfo 类作为流。这样做的目的是为了学习,我并不是想解决一个项目的问题。

c# stream

0
推荐指数
1
解决办法
424
查看次数