我想有一个方法 可以绕过一个物体 以属性名称 并给我 财产的价值。
更具体地说,作为一个输入,我有一个像“ 模型. child. Name ” 的字符串, 我想用这个方法来取一个对象, 然后从程序上给我找到的值, 可以通过 对象. 模式. child. Name 找到 。
我理解这样做的唯一途径是使用反省,但我不想自己写这个代码,因为我认为有陷阱。 此外,我认为这或多或少是通常的任务。
在C#上有没有使用这种算法的著名方法?
我想有一个方法 可以绕过一个物体 以属性名称 并给我 财产的价值。
更具体地说,作为一个输入,我有一个像“ 模型. child. Name ” 的字符串, 我想用这个方法来取一个对象, 然后从程序上给我找到的值, 可以通过 对象. 模式. child. Name 找到 。
我理解这样做的唯一途径是使用反省,但我不想自己写这个代码,因为我认为有陷阱。 此外,我认为这或多或少是通常的任务。
在C#上有没有使用这种算法的著名方法?
Reflection 是前进的道路。
您可以查看 < a href=> http://objectdumper.codeplex.com/" rel="nofollow" >ObjectDumper 并按您的要求修改源代码 。
对象Dumper 取一个.NET 对象并将其倾弃到字符串、文件、文本Writer 等。
写作并不难,但有一些陷阱,但了解这些陷阱是件好事。
算法是直截了当的, 它绕过树结构。 在每一个节点上, 你检查它是否具有原始值( int, string, char, etc), 如果它不是这些时间中的任何一个时间, 那么它的结构就有一个或几个原始, 需要穿行到原始。
这些陷阱涉及空洞、无效类型、价值与参考类型等。 每一个开发者都应该知道的直线前进的东西。
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...