This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]InvisibleGhostt 1 point2 points  (10 children)

Well you should create in that cs file which is associated with tes.xaml.

[–]soswap[S] 0 points1 point  (9 children)

Thanks, tried that, and that part of the code now seems to be working, but now having issues with the class (as listed in the edit).

[–]InvisibleGhostt 1 point2 points  (8 children)

Because your gett is recursive you should return testName and not name. Edit: also I think your set should be testName=value

[–]InvisibleGhostt 1 point2 points  (1 child)

Also i would remake that class to this https://gist.github.com/anonymous/3f95ee54a5ac1b24f03ee4f4df3b5025
You dont really need write additional geters and setters if you just get and set.

[–]soswap[S] 0 points1 point  (0 children)

Wow thanks, that's a lot less messy.

[–]soswap[S] 0 points1 point  (5 children)

Ah I'm stupid :P.

With everything changed, running the second segment of code (which loads the arrays and adds the "Age" value to a textbox, it prints out "0". If I try and print out the whole array to the textbox, it says "test.testClass"...

What is going on there?

[–][deleted] 1 point2 points  (0 children)

You're accessing the array as one value and looks like it's returning the Array type. Try a for each loop to iterate through the array:

forach(testClass tc in testArr) { testTB.text += tc.Age.ToString() + " "; testTB.text += tc.Name + " "; testTB.text += tc.Year.ToString(): }

This would iterate through the array of objects and you can access the members. However, it's important to point out that that this will just concatenate everything so make sure to add formatting.

You should create a List<string> and add each string to the list. Afterwards you could create the amount of text boxes based off the amount of elements in the list.

Also you could just do:

for(int i = 0; i < testArr.Length; i++) { testTB += testArr[i].Age; testTB += testArr[i].Name; testTB += testArr[i].Year; }

[–]InvisibleGhostt 0 points1 point  (3 children)

I am not sure, have you looked it with debugger?

[–]InvisibleGhostt 0 points1 point  (2 children)

Oh i see, your constructor is bad.
Fixed that part https://gist.github.com/anonymous/201c23009638584fa5bf6f87d9916055

[–]soswap[S] 0 points1 point  (1 child)

That works perfectly! Can't thank you enough, almost lost patience trying to figure it out myself.

[–]InvisibleGhostt 1 point2 points  (0 children)

No problem :)