Lewis Cao

Lewis Cao

  • NA
  • 1
  • 3.2k

Converting strings into alternate Caps in C#

May 3 2014 11:02 PM
convertToAltCaps("hello") returns "hElLo" convertToAltCaps
("section is awesome") returns "sEcTiOn Is AwEsOmE" 
my program does not work when enter more than 4 letters 
Pls Help Me  
using System; 
using System.Collections.Generic; 
using System.Linq; using System.Text; 
using System.Threading.Tasks;  
namespace AltCap { 
class Program { 
static void Main(string[] args) { 
Console.WriteLine("Enter Your String: "); 
string s = Console.ReadLine(); 
StringBuilder b = new StringBuilder(s); 
for(int i = 1; i<b.Length;i+=2) { 
char c = Char.ToUpper(b[i]);             
b.Replace(b[i], c); } 
Console.WriteLine(b); 
Console.ReadKey(); } } 

Answers (6)