VB.Net 中带有委托的文本字符串

发布于 2024-11-09 10:38:50 字数 568 浏览 0 评论 0原文

我的 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."

现在提出了一些关于我应该如何完成作业的问题(其中一些是基于意见的),

你们认为我的老师所说的“反向词”是什么意思 。 order"?它们的意思是打印文本字符串随着单词组合向后(即“siht si a ecnetnes”),它们是否意味着打印整个单词向后的文本字符串(即“句子a是这个”),或者它们是否同时意味着两者(即“ecnetnes” a si siht")?这是基于意见的问题之一,但我只是想听听你们的想法。

其次,生成字符串中字符数的语法是什么?我已经知道获取字符串所需的代码数量话,但是这个作业的 b 部分让我有点困惑。任何帮助将不胜感激。

I was assigned the following project for my VB.Net programming course:

"Write a program using various procedures to perform the operations listed below. Call these procedures using delegates. Make sure to document your program and have the program print descriptive text along with the numbers in b. and 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."

Now this raises a couple of questions that I have (some of which are opinion-based) relating to how I should complete the assignment.

First off, what do you guys think my teacher means by "reverse word order"? Do they mean print a text string with the word compositions going backwards (i.e. "siht si a ecnetnes"), do they mean print a text string with the whole words going backwards (i.e. "sentence a is this"), or do they mean both at once (i.e. "ecnetnes a si siht")? This is one of the opinion-based questions, but I just wanted your guys' thoughts.

Secondly, what is the syntax to produce the number of characters in a string? I already know the code necessary to get the number of words, but part b of this assignment is confusing me slightly. Any help would be greatly appreciated.

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

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

发布评论

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

评论(2

零時差 2024-11-16 10:38:50

对于你的第二个问题,产生字符串中字符数的语法是:

Dim mystring as String = "This is a string"
Console.Writeline(mystring.Length)

// outputs 16

正如我在评论中提到的,我对你的第一个问题的猜测是老师想要颠倒单词,而不是字符,所以“这是一个句子” 会反向显示为“句子 a 是这个”

For your second question, the syntax to produce the number of characters in a string is:

Dim mystring as String = "This is a string"
Console.Writeline(mystring.Length)

// outputs 16

As I mentioned in my comments, my guess for your first question is that the teacher wants the words reversed, not the characters, so "this is a sentence" would appear in reverse as "sentence a is this"

巴黎盛开的樱花 2024-11-16 10:38:50

快速浏览了一下,因为它听起来很有趣。

    '   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)

Had a quick go at this because it sounded interesting.

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