我正在研究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) 我通过 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) 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) 我正在研究 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) 我正在研究接口,并遇到了一些奇怪的接口问题,其中的规则是我们必须实现公共接口方法。但是在这个例子中没有。
我尝试了从经验中学到的知识,发现的答案确实违反了规则。
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)
为什么会这样呢?
我正在 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: trueRun Code Online (Sandbox Code Playgroud)
我以为是 …
我在 Github 上有这个项目存储库,并且该存储库中有很多项目。
所以在我的场景中是这样的。
api-build-pipeline 项目-1:触发分支-1 ui-build-pipiline 项目-2:触发分支-1
因此,如果我只对project-1 有更新,则不应触发project-2,但如果它们的触发器是同一分支,我不知道该怎么做。
我想要像这样的触发器触发器:-branch-1 ..project-1
那可能吗?如果可能的话,我不希望他们使用不同的分支。
我将数据类型值存储到文件中然后使用它,但得到了错误的结果。我需要做什么才能得到正确的结果?
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# ×5
azure-devops ×3
azure ×2
.net ×1
.net-6.0 ×1
.net-core ×1
angular ×1
asp.net-core ×1
devops ×1
interface ×1
javascript ×1
node.js ×1
rxjs ×1
stream ×1
string ×1
typescript ×1