add Programmyday form github
This commit is contained in:
25
Stringaufgabe1/CharString.cs
Normal file
25
Stringaufgabe1/CharString.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Stringaufgabe1
|
||||
{
|
||||
internal class CharString
|
||||
{
|
||||
private string? _string;
|
||||
private int _index;
|
||||
public int CountCharInString(string s, char c)
|
||||
{
|
||||
this._string = s;
|
||||
this._index = _string.Split(c).Length -1;
|
||||
return _index;
|
||||
}
|
||||
public void PrintInfo()
|
||||
{
|
||||
Console.WriteLine($"Vorkommende Anzahl: {this._index}");
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Stringaufgabe1/Program.cs
Normal file
13
Stringaufgabe1/Program.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Stringaufgabe1
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
CharString charString = new CharString();
|
||||
Console.WriteLine("Geben Sie ihren Text ein und dann nach dem buchstaben den Sie zählen wollen: ");
|
||||
charString.CountCharInString(Console.ReadLine(),Convert.ToChar(Console.ReadLine()));
|
||||
charString.PrintInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Stringaufgabe1/Stringaufgabe1.csproj
Normal file
10
Stringaufgabe1/Stringaufgabe1.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>
|
||||
Reference in New Issue
Block a user