如何将数组和多维数组中的内容动态添加到文本字段?

发布于 2025-01-06 03:06:37 字数 453 浏览 3 评论 0原文

我正在使用数组和多维数组开发交互式测验类型游戏。

我试图创建一个动态文本字段,说“当前问题”+“抱歉,正确答案是...”+“数组中第一个答案字符串中的第二个答案”。

我想我已经很接近了,但是语法上有错误。

这是我尝试执行此操作的代码行:

questionHolder.question.text=(String (cat4Questions[0]) + "Sorry, the correct answer is "+ String (cat4Answers[0,2]));

我收到此错误:

VerifyError: Error #1030: Stack depth is unbalanced. 1 != 0.

如果有人可以推荐我的语法的不同措辞以产生积极的结果,我会很高兴。

谢谢!格雷姆

I am working on an interactive quiz type game using arrays and multidimensional arrays.

I am trying to make a dynamic textfield say "the current question" + "Sorry, the correct answer is..." + "the second answer in the first string of answers in the array".

I think I am pretty close, but there is an error in the syntax.

Here is the line of code where I try to do this:

questionHolder.question.text=(String (cat4Questions[0]) + "Sorry, the correct answer is "+ String (cat4Answers[0,2]));

I am getting this error:

VerifyError: Error #1030: Stack depth is unbalanced. 1 != 0.

I would be happy if someone could recommend a different phrasing of my syntax that will yield positive results.

Thanks! Graeme

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硬不硬你别怂 2025-01-13 03:06:37

问题可能出在:cat4Answers[0,2]。访问多维数组的正确语法是 array[a][b] 而不是 array[a, b]。

假设您的数组在索引 2 处包含问题 0 的正确答案,您可以像这样 cat4Answers[0][2] 访问该答案。

The problem might be here : cat4Answers[0,2]. The right syntax to access multidimensional arrays is array[a][b] and not array[a, b].

Assuming your array contains the right answer for question 0 at index 2, you can access that like this cat4Answers[0][2].

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文