C# :: Aufgabe #27 :: Lösung #4
11 Lösungen
#27
Text abwechselnd in Groß- und Kleinschreibung
Anfänger - C#
von Dome
- 29.12.2012 um 01:34 Uhr
Schreiben Sie ein Programm, welches einen eingegeben Text so manipuliert, das der Text abwechselnd in Groß- und Kleinschreibung auf den Bildschirm ausgegeben wird.
Konsolenausgabe:
Texteingabe: Beispieltext
Textausgabe: BeIsPiElTeXt
#4
von wladi-g (1310 Punkte)
- 02.06.2014 um 16:38 Uhr
using System;
namespace GroßKleinAbwechslung
{
class Program
{
static void Main(string[] args)
{
char temp;
string text = "";
System.Console.Write("Texteingabe: ");
text = System.Console.ReadLine();
for (int i = 0; i < text.Length; i++)
{
if (i % 2 == 0)
{
temp = Char.ToUpperInvariant(text[i]);
text = text.Remove(i, 1);
text = text.Insert(i, temp.ToString());
}
else
{
temp = Char.ToLowerInvariant(text[i]);
text = text.Remove(i, 1);
text = text.Insert(i, temp.ToString());
}
}
System.Console.WriteLine("Textausgabe: {0}", text);
}
}
}
Kommentare:
Für diese Lösung gibt es noch keinen Kommentar
Seite 1 von 0
1
