English 中文(简体)
如何利用C#中强化阵列的内容
原标题:How to access the elements of a stringified array in C#

我是新的方案拟订工作,因此,请与我一起发言。

<<>Background

  1. 我创建了一个支部职能,收集了案文、顶顶和左侧各文本箱的坐标,我希望利用AJAX POST将所有这些信息通过C#的网络服务。

  2. 我成功地将这一数据通过到网络服务方法中,并在一个数据库中插入一个记录(我赢得了时间。

  3. In order to write data for multiple text boxes, I am using a jQuery function containing an array of objects, for which I have taken inspiration from the first option in the following post: Jquery multidimensional arrays

www.un.org/Depts/DGACM/index_spanish.htm 我的法典:

function Note(noteText, topCoord, leftCoord) {
    return {
        noteText: noteText,
        topCoord: topCoord,
        leftCoord: leftCoord
    }

var noteData = [];

function SaveNote() {
{ input ).filter("notes").each(function(index) {
var noteText = ($this)).val();
var coord = ($this)).offset();
var topCoord = coord.top;
var leftCoord = coord.left;

noteData.push(Note(noteText,topCoord,leftCoord));

var jsonText = JSON.stringify({ noteData : noteData});


});
  1. D. 警示变量json 案文 我收到下列文件:

    {"noteData":[{"noteText":"This is note text" ; "topCoord":23.33 ; "leftCoord":12.23}, {"noteText":"Note text 2" ; "topCoord":23.33 ; "leftCoord":12.23}]}

www.un.org/Depts/DGACM/index_spanish.htm 问题:

  1. This is great! But how can I decode this data within the web method in C# so that I can access each piece of data to eventually write a record to a SQL database for each Note object .

I hope this makes sense. Thank you in advance.

最佳回答

1. 创建你可以 des的阶级:

public class Note()
{
    public string noteText { get; set; }
    public float topCoord { get; set; }
    public float leftCoord { get; set; }
}

然后使用:

var jsSer = new JavaScriptSerializer();
Note note = jsSer.Deserialize(json);
问题回答




相关问题
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. ...

热门标签