草庐IT

Third_Parameter

全部标签

c# - 无效方差 : The type parameter 'T' must be contravariantly valid on 'UserQuery.IItem<T>.ItemList' . 'T' 是协变的

这个问题在这里已经有了答案:Tmustbecontravariantlyvalid(3个答案)关闭3年前。为什么方法可以编译,属性却报错?publicinterfaceIFoo{}publicinterfaceIBarwhereT:IFoo{}publicinterfaceIItemwhereT:IFoo{//IEnumerable>GetList();//worksIEnumerable>ItemList{get;set;}//Error!}错误:Invalidvariance:Thetypeparameter'T'mustbecontravariantlyvalidon'UserQ

c# - 使用 LINQ 在列表中查找项目但得到 "Value cannot be null. Parameter name: source"

当使用LINQ从列表中获取数据时,我遇到了这个错误。如何解决?Valuecannotbenull.Parametername:sourcevarnCounts=fromsaleinsalselectnew{SaleID=sale.OrderID,LineItem=fromsliinsale.LineItemsgroupslibysli.ItemintoItemGroupselectnew{Item=ItemGroup.Key,Weeks=ItemGroup.Select(s=>s.Week)}};foreach(variteminnCounts){foreach(varitmssini

c# - "Parameter not valid"加载System.Drawing.Image异常

为什么我的代码中出现“参数无效”异常:MemoryStreamms=newMemoryStream(byteArrayIn);System.Drawing.ImagereturnImage=System.Drawing.Image.FromStream(ms);byteArrayIn的长度是169014。尽管其中没有任何值大于255,但我得到了这个异常。 最佳答案 我遇到了同样的问题,现在显然已经解决了,尽管这个和其他一些gdi+异常非常具有误导性,但我发现实际上问题在于发送到Bitmap构造函数的参数无效。我有这段代码:using

C# "Parameter is not valid."创建新位图

如果我尝试创建大于19000像素的位图,我会收到错误消息:参数无效。我该如何解决这个问题??System.Drawing.Bitmapmyimage=newSystem.Drawing.Bitmap(20000,20000); 最佳答案 请记住,您正尝试使用该位图分配大量内存。引用http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/37684999-62c7-4c41-8167-745a2b486583/.NET可能会拒绝创建一个一次性耗尽那么多连续内存的图像。

c# - 系统参数异常 : The table type parameter must have a valid type name

我正在尝试将用户定义的表类型传递到C#中的查询中。类型定义为2列(组织和子组织)我的代码是这样的:DataSetds=newDataSet();try{DataTableFilteredOrgSubOrg=newDataTable("OrgSubOrgValueType");FilteredOrgSubOrg.Columns.Add("org",typeof(string));FilteredOrgSubOrg.Columns.Add("subOrg",typeof(string));FilteredOrgSubOrg.Rows.Add(org,orgsub);using(SqlCon

c# - "The parameters dictionary contains a null entry for parameter"- 如何修复?

我正在尝试实现一个编辑页面,以便管理员修改数据库中的数据。不幸的是,我遇到了一个错误。下面的代码:publicViewResultEdit(intproductId){//Dosomethinghere}但是我收到这个错误:"Theparametersdictionarycontainsanullentryforparameter'productId'ofnon-nullabletype'System.Int32'formethod'System.Web.Mvc.ViewResultEdit(Int32)'in'WebUI.Controllers.AdminController'.To

c# - MVC : The parameters dictionary contains a null entry for parameter 'k' of non-nullable type 'System.Int32'

我是MVC的新手。在我的应用程序中,我正在从Mydatabase中检索数据。但是当我运行我的应用程序时,它会显示这样的错误这是我的网址http://localhost:7317/Employee/DetailsData/4ExceptionDetails:System.ArgumentException:Theparametersdictionarycontainsanullentryforparameter'k'ofnon-nullabletype'System.Int32'formethod'System.Web.Mvc.ActionResultDetailsData(Int32)

C# 4.0 : Can I use a Color as an optional parameter with a default value?

这个问题在这里已经有了答案:C#4.0:CanIuseaTimeSpanasanoptionalparameterwithadefaultvalue?(8个答案)关闭9年前。publicvoidlog(Stringmsg,Colorc=Color.black){loggerText.ForeColor=c;loggerText.AppendText("\n"+msg);}这会导致c必须是编译时常量的错误。我已经阅读了一些内容,大多数示例都在处理字符串和整数。我发现我可以使用colorconverter类,但我不确定它是否非常有效。有没有办法将基本颜色作为可选参数传递?publicvoi

c# - ReSharper 好奇号 : "Parameter is only used for precondition check(s)."

为什么ReSharper会根据这段代码来评判我?privateControlGetCorrespondingInputControl(SupportedTypesupportedType,objectsettingValue){this.ValidateCorrespondingValueType(supportedType,settingValue);switch(supportedType){caseSupportedType.String:returnnewTextBox{Text=(string)settingValue};caseSupportedType.DateTime:

c# - "Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions"错误

为什么我收到错误:Templatescanbeusedonlywithfieldaccess,propertyaccess,single-dimensionarrayindex,orsingle-parametercustomindexerexpressions在此代码处:@modelIEnumerable@{ViewBag.Title="Index";Layout="~/Views/Shared/_PageLayout.cshtml";}Index@Html.ActionLink("CreateNew","Create")@foreach(variteminModel){@Html.