Tuesday, April 9, 2019

print string alternate uppercase c#


static void Main(string[] args)
        {
            string s = "abcdefgh";
            StringBuilder ss = new StringBuilder();

            for (int i = 0; i < s.Length; i++)
            {
                if (i % 2 == 0)
                {
                    ss.Append(s[i].ToString().ToUpper());
                }
                else
                {
                    ss.Append(s[i].ToString());
                   
            }
             


            }
            Console.WriteLine(ss);
            Console.ReadLine();
        }

No comments:

Post a Comment