草庐IT

get_comp_words_by_ref

全部标签

c# - 如何为数组数据成员定义 get 和 set?

我正在创建一个类Customer,它具有以下数据成员和属性:privatestringcustomerName;privatedouble[]totalPurchasesLastThreeDays;//arrayof3elementsthatwillholdthetotalsofhowmuchthecustomerpurchasedforthepastthreedaysi.e.element[0]=100,element[1]=50,element[2]=250publicstringCustomerName{get{returncustomerName;}set{customerNa

c# - System.StackOverflowException ,何时使用 get set 属性?

在wcfserviceLibrary.DLL中发生类型为“System.StackOverflowException”的未处理异常代码如下。[DataContract]publicclassmemberdesignations{[DataMember]publicstringDesigId{get{returnDesigId;}set{DesigId=value;}}[DataMember]publicstringDesignationName{get{returnDesignationName;}set{DesignationName=value;}}}然后我有如下的Typememb

c# - 将 set 访问器添加到类中的属性,该类派生自只有一个 get 访问器的抽象类

我有一个抽象类,AbsClass实现一个接口(interface),IClass.IClass有几个属性只有Get访问器。AbsClass实现的属性IClass作为要在派生自的类中定义的抽象属性AbsClass.所以所有派生自的类AbsClass还需要满足IClass通过与Get访问器具有相同的属性。但是,在某些情况下,我希望能够向来自的属性添加set访问器。IClass.然而,如果我尝试覆盖中的抽象属性AbsClass使用setaccessor我收到此错误ConcClassA.Bottom.Set无法覆盖,因为AbsClass.Bottom没有可覆盖的set访问器见ConcClass

c# - 为什么匿名委托(delegate)/lambda 不推断 out/ref 参数的类型?

StackOverflow上的几个C#问题询问如何使用out或ref参数制作匿名委托(delegate)/lambda。参见,例如:CallingamethodwithreforoutparametersfromananonymousmethodWritealambdaoranonymousfunctionthatacceptsanoutparameter为此,您只需指定参数的类型,如:publicvoiddelegateD(outTp);//...Da=(outTt)=>{...};//Lambdasyntax.Db=delegate(outTt){...};//Anonymousd

c# - Linq order by aggregate in select { }

这是我正在处理的一个:varfStep=frominspinsq.Inspectionswhereinsp.TestTimeStamp>dStartTime&&insp.TestTimeStamp我想按所选投影中的一个或多个字段排序。 最佳答案 最简单的更改可能是使用查询延续:varfStep=frominspinsq.Inspectionswhereinsp.TestTimeStamp>dStartTime&&insp.TestTimeStamp老实说,这基本上等同于使用“let”——真正的区别在于let引入了一个新范围变量,而查

c# - 逐行读取word文档

我正在尝试使用C#阅读word文档。我能够获取所有文本,但我希望能够逐行阅读并存储在列表中并绑定(bind)到gridview。目前我的代码只返回一个包含所有文本的项目列表(不是按需要逐行)。我正在使用Microsoft.Office.Interop.Word库来读取文件。下面是我的代码:Applicationword=newApplication();Documentdoc=newDocument();objectfileName=path;//DefineanobjecttopasstotheAPIformissingparametersobjectmissing=System.T

c# - 将简单的 SQL group-by 转换为 LINQ to SQL

我遇到了麻烦。我无法理解StackOverflow上对此的现有答案,而且我对LINQtoSQL太陌生,无法自己解决。查看此SQL:selectp.NameasProductName,SUM(o.NumberOf)asTotalOrderedfrom[Order]ojoin[Product]pono.ProductId=p.Idgroupbyp.Name返回一个漂亮的2列表,左侧是产品名称,右侧列是已订购(所有订单)的产品总数。我如何在LINQtoSQL中复制它?这是我到目前为止所得到的:varctx=newDataClasses1DataContext();vartotalProduc

c# - LINQ to Entities Group By 表达式给出 'Anonymous type projection initializer should be simple name or member access expression'

我在这个表达式中遇到了上述错误:varaggregate=fromtinentities.TraceLinesjoinminentities.MethodNames.Where("it.NameLIKE@searchTerm",newObjectParameter("searchTerm",searchTerm))ont.MethodHashequalsm.MethodHashwhere(t.CallTypeId&(int)types)==t.CallTypeId&&t.UserSessionProcessId==m_SessionIdgrouptbym.Nameintodselect

c# - 在类 C# 中使用 ref

我想为我正在制作的类(class)提供一个特定的链表。我希望类写入该列表(例如通过.addLast())。我应该为此使用ref关键字吗?我对在C#中在哪里使用ref和out关键字感到有些困惑,因为所有classes都是在堆上动态分配的,并且我们实际上使用指针进行大多数操作。当然,out和ref关键字对于基元和结构是有意义的。还有,如果我不直接发送列表,而是发送一个包含列表的类呢?(它是internal并且需要),我还需要使用ref吗?或者如果我在函数之间传递它,例如:voidA(refLinkedListlist){B(list);}voidB(refLinkedListlist){_

c# - 使用 RestSharp 将 GET 参数添加到 POST 请求

我想向这样的URL发出POST请求:http://localhost/resource?auth_token=1234我想在正文中发送JSON。我的代码看起来像这样:varclient=newRestClient("http://localhost");varrequest=newRestRequest("resource",Method.POST);request.AddParameter("auth_token","1234");request.AddBody(json);varresponse=client.Execute(request);如何将auth_token参数设置为G