VB.Net中带有代理的文本字符串

问题描述

| 我为VB.Net编程课程分配了以下项目: \“使用各种过程编写程序以执行下面列出的操作。请使用委托调用这些过程。确保记录您的程序,并让程序打印说明性文字以及b。和c中的数字。
a) Print a text string in reverse word order. 
b) Print the number of characters in the string.
c) Print number of words in the string.\"
现在,我提出了一些有关我应该如何完成作业的问题(其中一些是基于观点的问题)。 首先,你们认为我的老师用“反序”是什么意思?它们的意思是打印文本字符串时将单词组成向后移(即\“ siht ecnetnes \”),还是打印文本字符串时将整个单词向后移(即\“句子a is this \”),还是两者都同时意思(即“使人满意”)?这是基于意见的问题之一,但我只是希望你们的想法。 其次,产生字符串中的字符数的语法是什么?我已经知道获取单词数量所必需的代码,但是此作业的b部分使我有些困惑。任何帮助将不胜感激。     

解决方法

对于第二个问题,在字符串中产生字符数的语法为:
Dim mystring as String = \"This is a string\"
Console.Writeline(mystring.Length)

// outputs 16
正如我在评论中提到的那样,我对您的第一个问题的猜测是,老师希望单词反转,而不是字符,因此“这是一个句子”会反过来出现,因为“句子是这个”     ,快速浏览一下,因为它听起来很有趣。
    \'   Reverse the string and then print it to the output window
    Dim ReverseArray As Array = \"Print a text string in reverse word order.\".ToCharArray

    \'   Reverse the array to
    Array.Reverse(ReverseArray)

    \'   Convert the array back into a string (should be Reversed...)
    Debug.WriteLine(\"Reversed string = \'{0}\'\",New String(ReverseArray))

    \'   Get the number of Characters,remember a \"Space\" is still a Character
    Debug.WriteLine(\"Number of characters in array = {0}\",ReverseArray.Length)

    \'   Count the number of spaces in the string,then add an extra one
    Debug.WriteLine(\"Number of Words = {0}\",(From c In ReverseArray Where c.ToString = \" \" Select c).Count + 1)