我有字符串数组说 string str[] = {"a", "b"}
和 List<string> lst = new List<string> {"a", "b"}
如何确保字符串数组和列表包含相同的值.注意:值可以是任何顺序,但必须具有相同的频率.
任何人都可以告诉我如何在LINQ中做到这一点?
谢谢.
我有以下代码.如何将其转换为LINQ?任何人请帮助我.
在下面的代码中,'powd'包含db值,purchaseOrderUpdateRequest包含用户提交的数据.
bool hasUpdate;
foreach (var item in purchaseOrderUpdateRequest.Lines)
{
var line = powd.PurchaseOrderLines.Single(p => p.ItemNumber == item.ItemNumber);
decimal quantityToReceive = item.QuantityReceived - line.QuantityReceivedToDate;
if (quantityToReceive > 0)
{
hasUpdate =true;
break;
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
我有以下代码,有时ArchiveFiles()需要更多时间来完成其执行.
当用户从上下文菜单中多次单击退出选项时,如果ArchiveFiles()需要更多时间,则应用程序将无响应.如何再次单击退出选项时显示等待消息?
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
ArchiveFiles();
Application.Exit();
}
Run Code Online (Sandbox Code Playgroud)
谢谢
Bhaskar
我目前正在使用以下代码使用Foxit Reader软件打印pdf。现在我的问题是我想打印一个文件的多个副本。任何人都可以让我知道如何在以下代码中打印pdf时指定份数。
[编辑] 我不想使用循环来打印pdf的多个副本。我只想将其指定为命令行参数。
任何帮助表示赞赏:)
Process process = new System.Diagnostics.Process();
process.EnableRaisingEvents = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = foxitReaderInstalledPath;
string arguments = String.Format(@"-t ""{0}"" ""{1}""", this.Path, printerName);
process.StartInfo.Arguments = arguments;
process.Start();
process.WaitForExit();
Run Code Online (Sandbox Code Playgroud) 根据这篇文章,我试图绑定一个非顺序项列表.
视图:
<%using (Html.BeginForm("Products", "Home", FormMethod.Post))
{ %>
<input type="hidden" name="products.Index" value="cold" />
<input type="text" name="products[cold].Name" value="Beer" />
<input type="text" name="products[cold].Price" value="7.32" />
<input type="hidden" name="products.Index" value="123" />
<input type="text" name="products[123].Name" value="Chips" />
<input type="text" name="products[123].Price" value="2.23" />
<input type="hidden" name="products.Index" value="caliente" />
<input type="text" name="products[caliente].Name" value="Salsa" />
<input type="text" name="products[caliente].Price" value="1.23" />
<input type="submit" value="Submit" />
<%} %>
Run Code Online (Sandbox Code Playgroud)
行动方式:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Products(IList<Product> products)
{
return View("Index");
}
Run Code Online (Sandbox Code Playgroud)
绑定似乎对我不起作用,参数产品总是包含null.我错过了什么吗?
任何帮助非常感谢,谢谢.
请注意,我使用的是ASP.NET MVC 1.0
b/w以下两个代码有什么区别.在构造函数中使用'this'关键字有什么用?
例1:
public Product(string name){
this.Name = name;
}
Run Code Online (Sandbox Code Playgroud)
例2:
public Product(string name){
Name = name;
}
Run Code Online (Sandbox Code Playgroud)
我知道这是指调用对象.只是我无法得到差异?
有人可以解释一下吗?
我在文本框中有一个逗号分隔的字符串,我想将此字符串作为字符串数组传递给操作方法.谁能告诉我怎样才能实现这一目标.谢谢.
我正在使用MVC 1.0.
浏览次数:
<input type="text" name="fruits" /> -- Contains the comma seperated values
Run Code Online (Sandbox Code Playgroud)
行动方法
public ActionResult Index(string[] fruits)
{
}
Run Code Online (Sandbox Code Playgroud) 我上课了.
public class Compaints
{
public string CustomerNumber{get; set;},
public string Complaint{get; set}
}
Run Code Online (Sandbox Code Playgroud)
我有一份投诉清单.我需要按customerNumber分组并将其添加到字典中说类型
Dictionary<string, int>- 字符串将是客户编号而int将是计数.
如何在linq中执行此操作?
谢谢.
我想使用bat文件构建安装项目,并希望生成msi。我尝试使用MSBuild.exe进行构建,如下所示
@echo off
call %windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe C:\Setup1\Setup1.sln
Run Code Online (Sandbox Code Playgroud)
但是,似乎MSBUILD不支持安装项目。还有其他想法使用bat文件构建安装项目吗?
我正在使用Asp.Net MVC应用程序.
在以下代码中,如何避免填充下拉列表的两个数据库调用?
[HttpGet]
public ActionList Upload(){
// do something
//For populating drop downlist take data from db
Return View("Upload");
}
[HttpPost]
public ActionList Upload(){
//do something
//again take data from db for populating dropdown
Return View("Upload");
}
Run Code Online (Sandbox Code Playgroud)
除了jQuery ajax方法之外的任何其他方式?谢谢
嗨,我在SP中有以下查询
@CrmContactId是SP的参数.
Select distinct A.PolicyBusinessId, A.PolicyDetailId
from TPolicyBusiness A
inner join TPolicyOwner B on a.PolicyDetailId=b.PolicyDetailId
Left Join TAdditionalOwner C on c.PolicyBusinessId=A.PolicyBusinessId
where (b.CRMContactId = @CRMContactId)
Run Code Online (Sandbox Code Playgroud)
我们做了一个新的改变并引入了OR条件
Select distinct A.PolicyBusinessId, A.PolicyDetailId
from TPolicyBusiness A
inner join TPolicyOwner B on a.PolicyDetailId=b.PolicyDetailId
Left Join TAdditionalOwner C on c.PolicyBusinessId=A.PolicyBusinessId
where (b.CRMContactId = @CRMContactId OR C.CRMContactId = @CRMContactId)
Run Code Online (Sandbox Code Playgroud)
执行计划:

附件:执行计划
但是这种变化在实时服务器中引起了巨大的性能问题.TPolicyBusiness和TPolicyOwner是拥有数百万条记录的重型表.TAdditionalOwner表是一个只有很少记录的灯表.
为了解决这个问题,Union all代替了OR条件.
Select distinct A.PolicyBusinessId, A.PolicyDetailId
From
(
Select A.PolicyBusinessId, A.PolicyDetailId
from TPolicyBusiness A
inner join TPolicyOwner B on a.PolicyDetailId=b.PolicyDetailId
where b.CRMContactId = …Run Code Online (Sandbox Code Playgroud) public partial class Form1 : Form
{
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
}
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
Run Code Online (Sandbox Code Playgroud)
当我运行上面的代码时,它调用了该方法 protected override void WndProc(ref Message m)
当我改变代码如下
Form1 form1 = new Form1();
Application.Run();
Run Code Online (Sandbox Code Playgroud)
它没有调用该方法 protected override void WndProc(ref Message m)
任何人都能解释我为什么会这样吗?
c# ×9
.net ×4
asp.net-mvc ×3
linq ×3
winforms ×2
batch-file ×1
msbuild ×1
overriding ×1
pdf ×1
printing ×1
sql ×1
sql-server ×1
union-all ×1