Write a program in VB.net to convert every odd position words into uppercase using StringBuilder

Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 1021
The following function will do so

Public Function StrResult() As String
Dim strBuilder = New StringBuilder()

'input string
Dim input As String = "Hello! i am learning vb.net. It is a nice language to start with and also has multiple features.one among them in stringbuilder"

'split the string using space as a delimeter
Dim inputArray = input.Split(" "C)

'find the length of the string
Dim stringLength As Integer = inputArray.Length

Enumerable.Range(0, stringLength).ToList().ForEach(Function(i)
If i Mod 2 <> 0 Then
inputArray(i) = inputArray(i).ToUpper()
End If
strBuilder.Append(" "C + inputArray(i))

End Function)
'return the value
Return strBuilder.ToString()
End Function


 Hello! I am LEARNING vb.net. IT is A nice LANGUAGE to START with AND also HAS multiple FEATURES.ONE among THEM in STRINGBUILDER

Comments or Responses

Login to post response