Skip to content

Instantly share code, notes, and snippets.

@suchja
Created December 21, 2016 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suchja/38996c238cd6c3209f63ad5e65e3bcd6 to your computer and use it in GitHub Desktop.
Save suchja/38996c238cd6c3209f63ad5e65e3bcd6 to your computer and use it in GitHub Desktop.
Quellcode zur ersten Folge von #FragLernMoment. Frag von Zaidi!
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