本文介绍了我如何解决该准则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

输入:Dim str As String =C:/ Ram / Ram1 / Ram2



这是一个硬编码输入,意味着我们想要的变量将其初始化为String。条件是我们只能使用一个打印选项。



输出:

C:/ Ram

C:/ Ram / Ram1

C:/ Ram / Ram1 / Ram2



请解决这个问题,为此我会感谢他/她。

Input : Dim str As String = "C:/Ram/Ram1/Ram2"

It is a hard coded input, means inside a variable we want to initialize this as a String. And the condition is we can use only one print option.

Output :
C:/Ram
C:/Ram/Ram1
C:/Ram/Ram1/Ram2

Please solve the question, for this i will be thankful to him/her.

推荐答案

Dim str As String = "C:/Ram/Ram1/Ram2"
Dim parts As String() = str.Split("/"C)
Dim sb As New StringBuilder()
Dim sep As String = ""
For Each s As String In parts
    sb.AppendFormat("{0}{1}", sep, s)
    sep = "/"
    Console.Writeline(sb.ToString())
Next


这篇关于我如何解决该准则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-26 04:43