草庐IT

reflect.Value

全部标签

c# - 最佳实践 : ref parameter or return value?

其实我是做一个列表作为引用参数如下:publicstaticListListMethod(Listresult)我也看到有人这样做:publicstaticvoidListMethod(refListresult)如果我没记错的话,“my”方法也将list作为引用参数,您应该可以像“other”在他的方法中一样使用它。但在我看来,您输入一个参数,对它做一些事情并在方法返回值中返回它似乎更“干净”。支持或反对一种方法或另一种方法的任何好的论据? 最佳答案 可能您不需要使用ref-但是有区别的。通常当我看到人们使用ref作为引用类型参数

c++-cli - C++/CLI-问题: Is there an equivalent to the C# "is" keyword or do I have to use reflection?

我在MSDN的某个地方读到过,与C#的“is”关键字等效的是dynamic_cast,但这并不完全等效:它不适用于值类型或泛型参数。例如在C#中我可以写:voidMyGenericFunction(){objectx=...if(xisT)...;}如果我尝试“等效的”C++/CLI:genericvoidMyGenericFunction(){objectx=...if(dynamic_cast(x))...;}我收到编译器错误“errorC2682:cannotuse'dynamic_cast'toconvertfrom'System::Object^'to'T'”。我唯一能想到的

c# - "Inspecting the state of an object in the debuggee of type System.Reflection.MethodBase is not supported in this context"

我不知道这个错误是什么意思。我使用的是VisualStudioforMac7.5.0社区版。我在带有ASP.NETCore的EntityFramework中使用延迟加载。publicpartialclassAdminUser{publicAdminUser(){RoleAssign=newHashSet();}publicGuidUserId{get;set;}publicstringFirstName{get;set;}publicstringLastName{get;set;}publicstringEmail{get;set;}publicstringUserName{get;s

c# - 尝试打开 telerik 报告时出现 "Value cannot be null. Parameter name: instance"错误

在我的解决方案中,我有telerik报告,当尝试在VisualStudio2010设计器中打开它们时,我收到此错误:Valuecannotbenull.Parametername:instanceCallStackatSystem.ComponentModel.TypeDescriptor.AddAttributes(Objectinstance,Attribute[]attributes)atMicrosoft.VisualStudio.Design.VSDesignSurface.CreateDesigner(IComponentcomponent,BooleanrootDesig

c# - 使用 Reflection.Emit 创建一个实现接口(interface)的类

我需要使用实现以下接口(interface)的Reflection.Emit生成一个类。publicinterfaceIObject{TGet(stringpropertyName);}有没有人举例说明我将如何发出以下内容作为简单的测试用例?classGeneratedObject:IObject{publicTGet(stringpropertyName){//thisisthesimplestpossibleimplementationreturndefault(T);}} 最佳答案 如果您正在使用Reflection.Emit

c# - ASP.NET MVC 如何知道如何填充您的模型以提供 Controller 的操作?它涉及反射(reflection)吗?

定义了一个模型publicclassHomeModel{[Required][Display(Name="FirstName")]publicstringFirstName{get;set;}[Required][Display(Name="Surname")]publicstringSurname{get;set;}}并具有以下ControllerpublicclassHomeController:Controller{[HttpPost]publicActionResultIndex(HomeModelmodel){returnView(model);}publicActionRe

c# - 是否有任何有值(value)的 CSLA 替代品可用?

我的公司有兴趣将大型业务应用程序移植到.NET。我们计划开发桌面版和silverlight版。我主要研究了CSLA框架(得到了rocky的书,已经读了一半)并发现它有点过度设计,数据层方面似乎也没有那么完善。有没有其他框架声称可以做CSLA正​​在做的事情?我不是在谈论ORM工具(例如L2S、EF、NHibernate)。我感兴趣的是支持业务规则的框架、简单的n层架构、对象是域驱动的而不是数据库驱动的、业务对象的安全性等...我知道我可以找到小型框架来完成一些所需的工作(我想到了EnterpriseApplicationBlock),但我正在寻找一个包含所有内容的框架。

c# - "+"在成员 c# 之后反射(reflect)的全名和 '*' 是什么意思#

我目前正在处理C#中的反射。之后:Assembly.LoadFile(@"C:\ProgramFiles\dotnet\shared\Microsoft.NETCore.App\2.0.7\System.Numerics.Vectors.dll").GetTypes()我发现了这个:[System.Numerics.Matrix4x4]、[System.Numerics.Matrix4x4+CanonicalBasis]、[System.Numerics.Matrix4x4+VectorBasis](有来自“System.Numerics.Vectors.dll”的反射类型)我知道Ma

c# - 我试图理解我反射(reflect)过的微软的 Do​​ubleUtil.AreClose() 代码

如果您反射(reflection)WindowsBase.dll>MS.Internal.DoubleUtil.AreClose(...),您将获得以下代码:publicstaticboolAreClose(doublevalue1,doublevalue2){if(value1==value2){returntrue;}doublenum2=((Math.Abs(value1)+Math.Abs(value2))+10.0)*2.2204460492503131E-16;doublenum=value1-value2;return((-num2num));}我试图理解两件不同的事情:

c# - System.Reflection.Assembly 的空引用异常

我开发了一个用于内部电子邮件报告的库。当我从另一个项目使用该库时(通过添加引用)。它在下一行给出了NullReferenceException。System.Reflection.Assembly.GetEntryAssembly().GetName().Name知道为什么Assembly为空吗? 最佳答案 这是预期的,尤其是在由非托管运行时加载的Windows服务中。使用:Process.GetCurrentProcess().MainModule.FileName获取非托管入口点文件。更新看来您正在寻找这个:System.Ref