草庐IT

open-generics

全部标签

c# - Open/SaveFileDialog 类之间的区别及其在 WPF 窗体中的使用

很好奇,但只是想知道是否有人知道使用之间的区别:System.Windows.Forms.SaveFileDialog(在AssemblySystem.Windows.Forms.dll中)和Microsoft.Win32.SaveFileDialog(在AssemblyPresentationFramework.dll中)?我在WPF表单中使用PresentationFramework.dll版本,但目前正在重新使用表单中的一些旧代码,其中包括显示System.Windows.Forms.dll版本并想知道是否:它们的外观有细微差别吗?使用System.Windows.Forms.S

c# - 无法将带有 [] 的索引应用于 mvc Controller 中类型为“System.Collections.Generic.ICollection<int>”的表达式

publicActionResultaddstandardpackage1(ICollectionSingleStay,ICollectionDOUBLESTAY,ICollectionTRIBLESTAY,ICollectionFAMILYSTAY,ICollectionEXTRABED){vars=SingleStay;for(inti=0;i在for循环中,我收到类似无法将带[]的索引应用于类型表达式的错误,但我需要在for循环中,在我得到的每个中。因为基于for循环,我会将详细信息与其他集合列表绑定(bind)。请帮助我。我在varcal=Singlestay[i]中遇到错误。

c# - 'System.Collections.Generic.List<float >' does not contain a definition for ' Sum'

我正在尝试使用内置的Sum()函数对float列表求和,但我不断收到此错误:ErrorCS1061:'System.Collections.Generic.List'doesnotcontainadefinitionfor'Sum'andnoextensionmethod'Sum'acceptingafirstargumentoftype'System.Collections.Generic.List'couldbefound(areyoumissingausingdirectiveoranassemblyreference?)(CS1061)我有usingSystem.Collect

c# - 取消 Item_Open 导致崩溃

我正在使用c#和Microsoft.Interop库编写办公插件。当我通过将Cancel属性设置为false取消在Item_Open事件中打开约会时,它会导致Outlook因Appcrash而崩溃。当打开与与会者的定期系列约会时,会发生崩溃。这在2016年有点新。在2010年和2013年它曾经有效。有人知道如何在2016年实现这一目标吗?我试图找出我的代码中的问题,但即使是示例也找到了here(这在其他方面也适用于2016年)如果我只是在AppointmentItem打开事件中将取消设置为true就会中断。编辑:我刚刚发现这只有在我禁用缓存模式时才会发生编辑2:我刚刚发现这只发生在20

c# - 使用带有 connection.open 的语句

我正在查看一些代码并与同事讨论。特别是一段看起来像这样的代码。[Test]publicvoidTestNormalWay(){using(varcn=GetConnection()){cn.Open();//dostuff}}问题来了:"whynotmovethecn.OpenintotheGetConnectionmethod."我说过,如果“打开”抛出异常,则不会调用处置。他的回答是"Sowhat.Theconnectionwasn'topenedsowhywoulditneedtogetclosed(ordisposed)?"对我来说,这只是我不想知道是否需要处理/关闭的问题,所

c# - 如何显示 "Open with"文件对话框?

有什么简单的方法可以打开“打开方式”文件对话框吗? 最佳答案 一些使用ProcExp的逆向工程揭示了一个rundll32.exe命令行是有效的。这是一个使用它的示例程序:usingSystem;usingSystem.Diagnostics;usingSystem.IO;classProgram{staticvoidMain(string[]args){ShowOpenWithDialog(@"c:\temp\test.txt");}publicstaticvoidShowOpenWithDialog(stringpath){var

C# : Passing a Generic Object

我想要一个通用的打印函数...PrintGeneric(T)...在下面的例子中,我缺少什么?一如既往地感谢您的帮助/见解...publicinterfaceITest{}publicclassMyClass1:ITest{publicstringmyvar="hello1";}publicclassMyClass2:ITest{publicstringmyvar="hello2";}classDoSomethingClass{staticvoidMain(){MyClass1test1=newMyClass1();MyClass2test2=newMyClass2();Console

c# - 错误 : Cannot implicitly convert type 'void' to 'System.Collections.Generic.List'

我正在尝试使用该控件从.ascx设置我的.ascx控件的属性。所以在我的一个包含此控件的.aspx中,我有以下代码试图设置我的嵌入式.ascx的ItemsList属性:Itemitem=GetItem(itemID);myUsercontrol.ItemList=newList().Add(item);我尝试设置的.ascx中的属性如下所示:publicListItemsList{get{returnthis.itemsList;}set{this.itemsList=value;}}错误:无法将类型“void”隐式转换为“System.Collections.Generic.List

C# 找不到类型或命名空间名称 `List'。但我正在导入 System.Collections.Generic;

我有一个错误Thetypeornamespacename`List'couldnotbefound.Areyoumissingausingdirectiveoranassemblyreference?示例代码:usingUnityEngine;usingSystem.Collections;usingSystem.Collections.Generic;publicclasscity1:MonoBehaviour{publicstaticListitems=newList();publicstaticListitemsprice=newList();publicstaticListqu

C# Open XML 2.0 NumberFormatId 范围

使用C#使用OpenXML2.0解析大型Excel文件。我遇到的问题是我正在解析的单元格没有数据类型,然后我检查NumberFormatId以确定它是小数、数字还是日期。我正在寻找数字/小数与日期的确切NumberFormatId范围。它们似乎无处不在,一些数字/小数的格式为189,212,214,305,日期的值为185、194、278等。有人知道规范是否定义了这些范围吗?已编辑-更多信息下面是xl文件夹中style.xml文件中194的数字格式示例。Excel工作表来自世界不同地区,所以我认为数字格式不同,但它们是否重叠?numFmtId194会是不同文化设置中的日期以外的其他内容