字符串连接不能使用我的类

时间:2012-06-14 01:37:09

标签: vb.net string-concatenation

我正在尝试将两个属性连接成一个字符串,如下所示:

public class thing 
    public property word() as string()
    public property count() as integer()
end class

Public class myApp
    dim a_thing as new thing
    redim a_thing.word(upperBnd)
    redim a_thing.count(upperBnd)

    'I go on to fill the a_thing.word and .count arrays
    'Then I try to display the results...but it doesnt work.
    for i=0 to a_thing.word.length-1
        debug.writeline("Word: " & a_thing.word(i) & "  Count: " & a_thing.count(i))
    next
end class

for语句只显示:

Word: [the_word_in_the_array] Word: [the_word_in_the_next_index] ...etc,         

没有新线......

如果我把它变成两个debug.writeline语句,我得到:

Word: [the_word_in_the_array] Count: [the_count_in_the_array]

这就是我想要的,但它在调试输出中没有帮助......我需要把它放到一个字符串中。我尝试过使用a_thing.count(i).tostring,但它不起作用。如果我单独查看数组,它们就具有我想要的内容。但我不能连接它们。这里发生了什么?它是否与抑制debug.writeline通常创建的新行有关?

1 个答案:

答案 0 :(得分:0)

检查Word数组中单词末尾是否有空字符。这会导致你看到的行为