jjzjj

Arguments

全部标签

c# - 如何使用 PostSharp 修改方法参数?

我需要用传递到我的方法中的参数做一些事情。我如何使用RestSharp与他们一起玩(修改)? 最佳答案 使用方法拦截,您可以使用Args.Arguments对象通过SetArgument方法更改值。[Serializable]publicclassMyAspect:MethodInterceptionAspect{publicoverridevoidOnInvoke(MethodInterceptionArgsargs){stringinput=(string)args.Arguments[0];if(input.Equals("1

c# - 如何使用 C# 获取 char**?

这个问题在这里已经有了答案:MarshalanarrayofstringsfromC#toCcodeusingp/invoke(2个答案)C#callC++DLLpassingpointer-to-pointerargument(3个答案)关闭6年前。我需要以以下形式将参数传递给不安全的DllImported函数:[DllImport("third_party.dll")]privatestaticexternunsafeintstart(intargc,char**argv);我假设它是一个字符串数组。但是,当我尝试执行以下操作时,出现“无法从字符串[]转换为char**”错误。我该

c# - Process.Start() 启动的应用程序未获取参数

使用C#,我尝试使用Process.Start()将命令行参数传递给新进程:stringpath=@"C:\Demo\Demo.exe";stringarguments="onetwothree";ProcessStartInfostartInfo=newProcessStartInfo{FileName=path,Arguments=arguments};varprocess=Process.Start(startInfo);我的C应用程序Demo.exe只是回显命令行参数:intmain(intargc,char*argv[]){intcount=0;//Displayeachco

c# - Rhino 模拟 - AssertWasCalled : How to improve unclear diagnostic message when incorrect arguments

恕我直言,RhinoMocks在使用AssertWasCalled时会产生一条不清楚的诊断消息,以验证是否已使用特定参数调用方法。例子:interfaceISomeInterface{voidWrite(strings);}[TestFixture]publicclassSomeTests{[Test]publicvoidWriteShouldBeCalledWithCorrectArguments(){//Arrangevarmock=MockRepository.GenerateMock();varsut=newSomeClass(mock);//Actsut.DoSomethin

c# - 在 C# 中,是否应该检查传递给方法的引用是否为 null?

嗯,几个月前我问过asimilarquestionaboutCandC++,但由于整个“WindowsPhone”问题,我最近更加关注C#。那么,在C#中,是否应该在方法边界检查NULL?我认为这与C和C++不同,因为在C#中,通常可以确定给定引用是否有效——编译器会阻止将未初始化的引用传递到任何地方,因此唯一可能的错误是它为null.此外,在.NETFramework中为这些东西定义了一个特定的异常,即ArgumentNullException。,这似乎将程序员认为在传递无效null时应该得到的东西编成法典。我个人的意见再次表明,这样做的调用者是错误的,并且说调用者应该向他们抛出NR

c# - Process.StartInfo.Arguments 是否支持 UTF-8 字符串?

可以使用UTF-8字符串作为StartInfo的参数吗?我正在尝试将UTF-8(在本例中为日语字符串)作为控制台参数传递给应用程序。类似这样的东西(这只是一个例子!(cmd.exe将是一个自定义应用程序))varprocess=newSystem.Diagnostics.Process();process.StartInfo.Arguments="/K\"echoこれはテストです\"";process.StartInfo.FileName="cmd.exe";process.StartInfo.UseShellExecute=true;process.Start();process.W

c# - 我可以使用类型化工厂设施返回基于(枚举)参数的实现吗?

不确定这是否可能。我需要根据枚举值返回正确的服务实现。所以手工编码的实现看起来像这样:publicenumMyEnum{One,Two}publicclassMyFactory{publicITypeIWantToCreateCreate(MyEnumtype){switch(type){caseMyEnum.OnereturnnewTypeIWantToCreate1();break;caseMyEnum.TworeturnnewTypeIWantToCreate2();break;default:returnnull;}}}返回的实现具有额外的依赖项,需要通过容器注入(inject

c# - The non-generic method cannot be used with type arguments in this context 是什么意思?

我有以下类和方法:publicclassUserManager:IDisposablewhereTUser:class,global::Microsoft.AspNet.Identity.IUserwhereTKey:global::System.IEquatable{publicvirtualTaskFindByIdAsync(TKeyuserId);和:privateApplicationUserManager_userManager;publicApplicationUserManagerUserManager{get{return_userManager??Request.Ge

c# - "This application could not be started."仅当文件在system32目录下

我写了一个从互联网上下载文件的小软件,仅此而已。我的意图是通过命令行使用它......它工作得很好,但是当我把它放在C:\Windows\System32\中以便从我想要的任何地方实际使用它时它现在不起作用......它没有抛出异常......它只是告诉我这个消息框-http://i.imgur.com/a7rlMgo.png如果我单击"is",它会在浏览器中打开此页面-http://support.microsoft.com/kb/2715633/en-us我应该怎么做才能使其正常工作?代码,如果它有任何用处......:privateconststringInsufficientP

C# 显示错误 'Delegate ' System.Func<...>' does not take 1 arguments

我打电话:form=newFormFor().Set(x=>x.Name,"hi");其中Project有一个名为Name的字段,FormFor的代码是:publicclassFormForwhereTEntity:class{FormCollectionform;publicFormFor(){form=newFormCollection();}publicFormForSet(Expression>property,stringvalue){form.Add(property.PropertyName(),value);returnthis;}}但它一直告诉我Delegate'Sy