c# - Windows Phone - Listbox items on array -
i have listbox on windows phone app, listbox receive values collection. put listbox items on array. so, need value first list item, received value app1.pivotpage1+fields
.
the collection item want show fnome
. how it?
my code:
private void button_click(object sender, routedeventargs e) { string[] array = new string[list2.items.count]; (int = 0; < list2.items.count; i++) { object s = list2.items[i]; array[i] = s.tostring(); } tjsonobject jobject = new tjsonobject(); tjsonpair jpair = new tjsonpair("test", array[0]); tjsonpair jpair1 = new tjsonpair("test1", "test1"); tjsonarray jarray = new tjsonarray(); jobject.addpairs(jpair); jobject.addpairs(jpair1); jarray.add(jobject); messagebox.show(jarray.tostring()); }
my collection:
public observablecollection<fields> items { get; set; } public class fields { [jsonproperty(propertyname = "fid")] public int fid { get; set; } public string fnome { get; set; } public float festado1 { get; set; } public string fpais { get; set; } public string quantity { get; set; } public string lero { get; set; } public string quantity1 { get; set; } public string festado { get; set; } }
my code working fine now. changed code:
private void button_click(object sender, routedeventargs e) { string[] array = new string[list2.items.count]; (int = 0; < list2.items.count; i++) { object s = list2.items[i]; array[i] = s.tostring(); } tjsonobject jobject = new tjsonobject(); tjsonpair jpair = new tjsonpair("test", array[0]); tjsonpair jpair1 = new tjsonpair("test1", "test1"); tjsonarray jarray = new tjsonarray(); jobject.addpairs(jpair); jobject.addpairs(jpair1); jarray.add(jobject); messagebox.show(jarray.tostring()); }
for this:
private void button_click(object sender, routedeventargs e) { fields[] array = list2.items.cast<fields>().toarray(); tjsonobject jobject = new tjsonobject(); tjsonpair jpair = new tjsonpair("fnome", array[0].fnome); tjsonpair jpair1 = new tjsonpair("test1", "test1"); tjsonarray jarray = new tjsonarray(); jobject.addpairs(jpair); jobject.addpairs(jpair1); jarray.add(jobject); messagebox.show(jarray.tostring()); }
Comments
Post a Comment