我想基于子集合属性对集合进行排序.
//the subcollection
public class Salary
{
public int SalaryId {get;set;}
public int SalaryYear {get;set;}
public double SalaryValue {get;set;} //this is the field we want to sort the parent collection "Person"
}
//the main collection
public class Person
{
public int PersonId {get;set;}
public string PersonName {get;set;}
public List<Salary> Salaries {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
以下仅用于测试目的,我正在准备我的人员收集工资内部收集每个:
List<Person> people = new List<Person>();
//add two salaries for Junior
people.Add(new Person { PersonId = 1, PersonName = "Junior" });
people[0].Salaries.Add(new Salary { SalaryId=1, SalaryYear=2011, SalaryValue=80000 }); …Run Code Online (Sandbox Code Playgroud) 我正在看这个Facebook指南文档,如果有可能,我正在徘徊:
早上好家伙
有没有一种在C#中使用正则表达式的好方法,以便在string变量中查找所有文件名及其路径?
例如,如果您有此字符串:
string s = @"Hello John
these are the files you have to send us today: <file>C:\Development\Projects 2010\Accounting\file20101130.csv</file>, <file>C:\Development\Projects 2010\Accounting\orders20101130.docx</file>
also we would like you to send <file>C:\Development\Projects 2010\Accounting\customersupdated.xls</file>
thank you";
Run Code Online (Sandbox Code Playgroud)
结果将是:
C:\Development\Projects 2010\Accounting\file20101130.csv
C:\Development\Projects 2010\Accounting\orders20101130.docx
C:\Development\Projects 2010\Accounting\customersupdated.xls
Run Code Online (Sandbox Code Playgroud)
编辑: 考虑到@Jim的内容,我编辑了字符串添加标签,以便更容易从字符串中提取所需的文件名!
我有一个包含NA的值向量.这些值需要由无法处理NA的外部程序处理,因此它们被剥离,写入文件,处理,然后读回,产生非NA数量长度的向量.例如,假设输入为7 3 4 NA 5 4 6 NA 1 NA,那么输出将只是7个值.我需要做的是将NA重新插入到位.
因此,给定两个向量X和Y:
> X
[1] 64 1 9 100 16 NA 25 NA 4 49 36 NA 81
> Y
[1] 8 1 3 10 4 5 2 7 6 9
Run Code Online (Sandbox Code Playgroud)
生产:
8 1 3 10 4 NA 5 NA 2 7 6 NA 9
Run Code Online (Sandbox Code Playgroud)
(你可能会注意到X是Y ^ 2,这只是一个例子).
我可以敲出一个函数来做这个,但我想知道是否有任何好的狡猾的方法做到这一点...分裂,列表,长度...嗯......
我想要一个属性到当前的项目ICollectionView我该怎么办?将ICollectionView用于绑定到一个组合框,我怎么可以绑定其他控件到ICollectionView所选项目的?
我们有一张桌子,里面有地方,有纬度和经度.
我们正在尝试在SQL Server 2008中创建一个函数,使用特定的纬度和经度作为中心点列出未来25公里内的位置.
如果这是一个很好的方法来启动和测试我们的功能并获得中心点(当前位置)和目标位置(@纬度/经度)之间的当前距离,我就会徘徊:
ALTER FUNCTION [dbo].[GetDistanceFromLocation]
(
@myCurrentLatitude float,
@myCurrentLongitude float,
@latitude float,
@longitude float
)
RETURNS int
AS
BEGIN
DECLARE @radiusOfTheEarth int
SET @radiusOfTheEarth = 6371--km
DECLARE @distance int
SELECT @distance = ( @radiusOfTheEarth
* acos( cos( radians(@myCurrentLatitude) )
* cos( radians( @latitude ) )
* cos( radians( @longitude ) - radians(@myCurrentLongitude) ) + sin( radians(@myCurrentLatitude) )
* sin( radians( @latitude ) ) ) )
RETURN @distance
END
Run Code Online (Sandbox Code Playgroud)
这是正确的还是我们遗漏了什么?
我已经使用在Stackoverflow上找到的建议使用powershell生成了证书:
New-SelfSignedCertificate -Subject "CN=Test Code Signing" -Type CodeSigningCert -KeySpec "Signature" -KeyUsage "DigitalSignature" -FriendlyName "Test Code Signing" -NotAfter (get-date).AddYears(5)
Run Code Online (Sandbox Code Playgroud)
我已将此证书复制并粘贴到“受信任的根证书颁发机构”中。
我的NET Core WebAPI Program.cs设置如下:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(options=> {
options.Listen(IPAddress.Loopback, 5000); // http:localhost:5000
options.Listen(IPAddress.Any, 80); // http:*:80
options.Listen(IPAddress.Loopback, 443, listenOptions =>
{
//how to use a certificate store here?
//listenOptions.UseHttps("certificate.pfx", "password");
//listenOptions.UseHttps(StoreName.My, "Test Code Signing", allowInvalid: true);
listenOptions.UseHttps(StoreName.My, "localhost", allowInvalid: true);
});
});
Run Code Online (Sandbox Code Playgroud)
无论是本地主机或测试代码签名在这个代码工作,因为他们无法找到。也许我缺少了一些东西。试图遵循此MSDN文档,但没有运气。
目前,Chrome浏览器上显示的证书与我在个人和受信任的根证书颁发机构中拥有的证书不同 …
c# https ssl-certificate kestrel-http-server asp.net-core-webapi
我想在TabControl中的第一个和最后一个TabItems上设置一个样式,并在TabItems的可见性发生变化时更新它们.我无法通过触发器看到这样做的方法.
我们所追求的是这样的:
| > > > |
TabItems的可见性由绑定决定.
我确实让它在代码中工作.在TabItem可见性更改时,通过TabItem枚举,直到找到第一个可见的.在那个上设置样式.对于所有其他可见的TabItems,将它们设置为尖头样式(以便先前第一个可见的TabItem现在是尖的).然后从结尾开始,直到找到一个可见的TabItem并在那个上设置最后一个样式.(这也让我们解决TabControl的问题,如果没有选择任何可见的TabItem,它将显示不可见的TabItem的内容.)
我可以对我的方法做出无可置疑的改进,但我不相信它是正确的方法.
你会怎么做?
我正在使用Visual Studio 2010.
我已经下载了一个更新的类(即UpdatedClass.cs),它有一个带有可选参数的方法,例如:
public void DoThis(bool aValue = false) {...}
Run Code Online (Sandbox Code Playgroud)
使用Visual Studio 2010,我可以编译它.但我不能用MSBuild做到这一点:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe /t:Rebuild /clp:ErrorsOnly D:\folder\mySolution.sln
ln
Microsoft (R) Build Engine Version 3.5.30729.5420
[Microsoft .NET Framework, Version 2.0.50727.5448]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
UpdatedClass.cs(29,94): error CS0241: Default parameter specifiers are not permitted
Run Code Online (Sandbox Code Playgroud)
好吧,使用此编译器不允许使用可选参数.那么我可以在这个MSBuild命令中添加一个额外的参数,以忽略这种错误吗?
或者我是否必须使用编译项目C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe?关于asp.net项目这是安全的吗?
为什么使用可绘制形状设置布局背景会在Android Studio 1.4上发出警告,提示无法设置背景RelativeLayout?
Android Studio关于无效背景的警告:
可绘制shape用作背景: