Write a program in C# to convert every odd position words into uppercase using StringBuilder

Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 1240
The following function will do so

public string StrResult()
var strBuilder = new StringBuilder();

//input string
string input = "Hello! i am learning c#. 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
var inputArray = input.Split(' ');

//find the length of the string
int stringLength = inputArray.Length;

.Range(0, stringLength)
i =>
if (i % 2 != 0) inputArray[i] = inputArray[i].ToUpper();
strBuilder.Append(' ' + inputArray[i]);
//return the value
return strBuilder.ToString();


 Hello! I am LEARNING c#. 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