add Programmyday form github
This commit is contained in:
37
DoublingExtention/Program.cs
Normal file
37
DoublingExtention/Program.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace DoublingExtention
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string input = "Libelle";
|
||||
Console.WriteLine(input.Doubling());
|
||||
}
|
||||
}
|
||||
static class DublingExtention
|
||||
{
|
||||
public static string Doubling(this string input)
|
||||
{
|
||||
char previosChar = '\0'; //PreviosChar wird beim ersten druchlauf nicht geprüft.
|
||||
char doubling;
|
||||
for (int i = 0; i < input.Length; i++)
|
||||
{
|
||||
char currentChar = input[i];
|
||||
if (i != 0)
|
||||
{
|
||||
previosChar = input[i - 1];
|
||||
}
|
||||
if (currentChar == previosChar)
|
||||
{
|
||||
doubling = currentChar;
|
||||
return $"Folgende doppelte Buchstaben wurden gefunden: {doubling}";
|
||||
}
|
||||
}
|
||||
return "Es wurden keine doppelten Buchstaben gefunden.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user