草庐IT

ref-parameters

全部标签

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# - With.Parameters.ConstructorArgument 与 ninject 2.0

如何在ninject2.0中使用这个功能?MyTypeobj=kernel.Get(With.Parameters.ConstructorArgument("foo","bar"));没有“With”:( 最佳答案 [Fact]publicvoidCtorArgTestResolveAtGet(){IKernelkernel=newStandardKernel();kernel.Bind().To();varwarrior=kernel.Get(newConstructorArgument("weapon",newSword()))

C# ref 是像 C/C++ 中的指针还是 C++ 中的引用?

我正在使用ref并且没有清楚地理解“它是像C/C++中的指针还是像C++中的引用?”为什么我问了你一时想的这么弱的问题?因为,当我阅读C#/.NET书籍、msdn或与C#开发人员交谈时,我会因以下原因而感到困惑:C#开发人员建议不要在函数的参数中使用ref,例如...(refTypesomeObject)对他们来说闻起来不好,他们建议...(TypesomeObject),我真的不清楚这个建议。我听到的原因:最好使用对象的副本,然后将其用作返回值,不要通过引用破坏内存等......我经常听到有关DB连接对象的解释。根据我的普通C/C++经验,我真的不明白为什么在C#中使用引用是一件坏事

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# - 为什么迭代器方法不能采用 'ref' 或 'out' 参数?

我今天早些时候试过这个:publicinterfaceIFoo{IEnumerableGetItems_A(refintsomethingElse);IEnumerableGetItems_B(refintsomethingElse);}publicclassBar:IFoo{publicIEnumerableGetItems_A(refintsomethingElse){//Ok...}publicIEnumerableGetItems_B(refintsomethingElse){yieldreturn7;//CS1623:Iteratorscannothavereforoutpa

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#属性和ref参数,为什么不加糖?

我刚刚在使用C#时遇到了这个错误消息Apropertyorindexermaynotbepassedasanoutorrefparameter我知道是什么原因造成的,并快速解决了创建一个正确类型的局部变量,用它作为out/ref参数调用函数,然后将其分配回属性:RefFn(refobj.prop);变成{vart=obj.prop;RefFn(reft);obj.prop=t;}很明显,如果属性在当前上下文中不支持get和set,这将失败。为什么C#不直接为我做这件事?我能想到的唯一可能导致问题的情况是:线程异常(exception)情况对于线程,转换会影响写入发生的时间(在函数调用之

c# - 属性或索引器不能作为 out 或 ref 参数传递

我收到上述错误并且无法解决。我用谷歌搜索了一下,但无法摆脱它。场景:我有一个BudgetAllocate类,它的属性是budget,它是double类型。在我的dataAccessLayer中,在我的一个类(class)中,我正在尝试这样做:double.TryParse(objReader[i].ToString(),outbd.Budget);这是抛出这个错误:Propertyorindexermaynotbepassedasanoutorrefparameteratcompiletime.我什至试过这个:double.TryParse(objReader[i].ToString(

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: