草庐IT

date_out

全部标签

C# 4.0 'dynamic' 没有设置 ref/out 参数

我正在试验DynamicObject。我尝试做的一件事是设置ref/out参数的值,如下面的代码所示。但是,我无法正确设置Main()中的i和j的值(即使它们在TryInvokeMember())。有谁知道如何使用ref/out参数调用DynamicObject对象并能够检索方法中设置的值?classProgram{staticvoidMain(string[]args){dynamicproxy=newProxy(newTarget());inti=10;intj=20;proxy.Wrap(refi,refj);Console.WriteLine(i+":"+j);//Print"

c# - .Net WebServices 和 out/ref WebMethod 参数

我从我们的供应商之一那里收到了一些他们正在发布的网络服务的文档,他们非常具体地指出,在他们的一个WebMethods上,一个参数有out修饰符(?不确定这是否是正确的描述符)例如考虑以下WebMethod签名:[WebMethod]publicvoidHelloWorld(outstringstrVal){strVal="HelloWorld";}[显然实际方法不是HelloWorld方法]现在,我从未考虑过设计带有out/ref参数的WebMethod,这让我想知道他们为什么会使用它。为了理解这个设计决定的应用,我将一个原型(prototype)和一些基本的HelloWorld风格的

c# - 如何在 ASP.Net 中检索上传文件的 "Last Modified Date"

我正在开发一个网站,客户端上传一些文档文件,如doc、docx、htm、html、txt、pdf等。我想检索上传文件的最后修改日期。我创建了一个处理程序(.ashx)来完成保存文件的工作。Followingisthecode:HttpPostedFilefile=context.Request.Files[i];stringfileName=file.FileName;file.SaveAs(Path.Combine(uploadPath,filename));如您所见,使用file.SaveAs()方法保存文件非常简单。但是这个HttpPostedFile类没有公开任何属性来检索文件

c# - 错误 : A project with an out put type of class library

我试图找出.net并得到这段代码,当我尝试从VS2008运行时它给我这个错误AprojectwithanOutputTypeofClassLibrarycannotbestarteddirectly.Inordertodebugthisproject,addanexecutableprojecttothissolutionwhichreferencestothelibraryproject.Settheexecutableprojectasthestartupproject我正在学习C#,所以不知道该做什么 最佳答案 您不能运行库。

c# - 为什么不能将属性作为 out 参数传递?

例如:int?qID=null;answer.QuestionID=int.TryParse(lblID.Text,outqID.Value)?qID:null;//Error:PropertyorIndexermaynotbepassedasanoutotrefparameter.微软文档中说:“作为out参数传递的变量不需要初始化。但是,必须在方法返回之前为out参数赋值。”然后:“属性不是变量,不能作为输出参数传递。那么底层.net平台设计禁止通过out设置对象的属性的原因是什么?out的值也不必是引用对象——使用值类型是完全合法的。那为什么不呢? 最

c# - string.split() "Out of memory exception"读取制表符分隔文件时

我在我的C#代码中使用string.split()来读取制表符分隔的文件。我正面临下面代码示例中提到的“OutOfMemory异常”。这里我想知道为什么文件大小为16MB时会出现问题?这是正确的方法吗?using(StreamReaderreader=newStreamReader(_path)){//...........Loadthefirstlineofthefile................stringheaderLine=reader.ReadLine();MeterDataIPValueListobjMeterDataList=newMeterDataIPValueL

c# - 如何从抛出异常的方法中通过 out/ref 参数获取值?

此代码输出“输出值”。classP{publicstaticvoidMain(){stringarg=null;try{Method(outarg);}catch{}Console.WriteLine(arg);}publicstaticvoidMethod(outstringarg){arg="outvalue";thrownewException();}}但是这个没有。classP{publicstaticvoidMain(){object[]args=newobject[1];MethodInfomi=typeof(P).GetMethod("Method");try{mi.In

c# - System.Net.Mail.SmtpException : The operation has timed out. 错误在asp.net发送邮件代码使用godaddy托管

我正在使用以下代码和平使用godaddy托管发送邮件。但它抛出System.Net.Mail.SmtpException:Theoperationhastimedout.protectedvoidsendmail(){varfromAddress="frommailid@site.com";//anyaddresswheretheemailwillbesendingvartoAddress="to@gmail.com";//PasswordofyourgmailaddressconststringfromPassword="mypassword";//Passingthevaluesa

c# - 用 C# "out parameters"嵌入单声道

我正在尝试使用libmono将C#类嵌入到C应用程序中,但文档有点缺乏。我正在尝试调用原型(prototype)为voidMessageToSend(outMessageObjectmessage);的方法我如何表示“输出参数”?它是指向MonoObject的指针吗?谢谢。附言。就libmono而言,'out'和'ref'参数是否相同? 最佳答案 你是对的,它是MonoObject**。out和ref除了C#编译器之外几乎所有东西都是一样的。 关于c#-用C#"outparameters

c# - SQL 日期问题 : How to get Yesterdays date in the following formatte

这是我目前的情况declare@TodaysmalldatetimeSet@Today=GETDATE()select@Todayyield2011-03-1013:46:00我需要的是:2011-03-09 最佳答案 试试这个:SELECTREPLACE(CONVERT(VARCHAR,DATEADD(dd,-1,GETDATE()),102),'.','-')GETDATE()返回当前日期/时间。DATEADD(dd,-1,GETDATE())从当前日期/时间减去一天。CONVERT(VARCHAR,@DATE,102)将日期转