Created
December 21, 2016 13:26
-
-
Save suchja/38996c238cd6c3209f63ad5e65e3bcd6 to your computer and use it in GitHub Desktop.
Quellcode zur ersten Folge von #FragLernMoment. Frag von Zaidi!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace FragLernMoment_1_InvertString | |
{ | |
// Frage von Zaidi: Bitte erkläre mir die Logik der Methode! | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string name = "Zaidi"; | |
string invertName = Invert(name); | |
Console.WriteLine(name + " - " + invertName); | |
Console.ReadLine(); | |
} | |
//Methode to invert text | |
static string Invert(string text) | |
{ | |
// erzeugt temporäres Feld von chars - wahrscheinlich um das resultat zu speichern | |
char[] myChar = new char[text.Length]; | |
for (int i = 1; i <= text.Length; i++) | |
{ | |
myChar[text.Length - i] = text[i - 1]; | |
} | |
return new string(myChar); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment