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;
Enumerable
.Range(0, stringLength)
.ToList()
.ForEach
(
i =>
{
if (i % 2 != 0) inputArray[i] = inputArray[i].ToUpper();
strBuilder.Append(' ' + inputArray[i]);
}
);
//return the value
return strBuilder.ToString();
}
Output
------- Hello! I am LEARNING c#. IT is A nice LANGUAGE to START with AND also HAS multiple FEATURES.ONE among THEM in STRINGBUILDER