add Programmyday form github
This commit is contained in:
10
DoublingExtention/DoublingExtention.csproj
Normal file
10
DoublingExtention/DoublingExtention.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
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