English 中文(简体)
• 如何从复杂钥匙的组合中建造C#物体
原标题:How to build C# object from a FormCollection with complex keys

i 有一个javascript Object,obj,通过一美元折中转至mvc行动。 同样:

var obj = {
    Items: [{ Text: "", Value: { Property1: "", Property2: "" },
            { Text: "", Value: { Property1: "", Property2: "" }]
};
$.post( MyAction , obj, function() {});

签署行动就是这样:

public ActionResult MyAction(FormCollection collection)
{
}

i 需要能够从<>FormCollection上打造一个物体,然而,在钥匙的形式上有一米:

"Items[0][Text]"
"Items[0][Value][Property1]"
"Items[0][Value][Property2]"
"Items[1][Text]"
"Items[1][Value][Property1]"
"Items[1][Value][Property2]"

i m 想知道,在上建立预期的C#物体是否有干净的途径。 i 理解,我可以改变行动方式签字,以适应感兴趣的一米物体,但提出自己的问题。

最佳回答

如果你能够改变 j子的侧面,以便你转而以 j子的形式发送数据,那么我认为,你要么接受一种扼杀,要么在控制器中玩 j,要么为你们效法。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

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. ...

NSArray s, Primitive types and Boxing Oh My!

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 ...

C# Marshal / Pinvoke CBitmap?

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 ...

How to Use Ghostscript DLL to convert PDF to PDF/A

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, ...

Linqy no matchy

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. ...

热门标签