add Programmyday form github
This commit is contained in:
10
IBANNummerPrüfen/IBANNummerPrüfen.csproj
Normal file
10
IBANNummerPrüfen/IBANNummerPrüfen.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>
|
||||
49
IBANNummerPrüfen/IbanPrüfung.cs
Normal file
49
IBANNummerPrüfen/IbanPrüfung.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IBANNummerPrüfen
|
||||
{
|
||||
public class IbanPrüfung
|
||||
{
|
||||
// Richtiges IBAN Format: DE68 2105 0170 0012 3456 78
|
||||
//private string? IBAN;
|
||||
private string? ibanCleared;
|
||||
private string? ibanSwapped;
|
||||
private string? sum;
|
||||
private string? iban;
|
||||
public void SetIbanPrüfungEntgegennehmen()
|
||||
{
|
||||
Console.Write("Bitte geben Sie ihre IBAN-Nummer ein: ");
|
||||
this.iban = Console.ReadLine();
|
||||
|
||||
Console.WriteLine(IBANPrüfung());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bestimmt ob die Checksumme einer IBAN gültig ist
|
||||
/// </summary>
|
||||
/// <param name="iban">Der zu prüfende IBAN (z.B: "DE68 2105 0170 0012 3456 78")</param>
|
||||
/// <returns><c>True</c>, wenn <paramref name="value"/> gültig ist. Andernfalls <c>False</c>.</returns>
|
||||
public bool IBANPrüfung()
|
||||
{
|
||||
if (this.iban != null)
|
||||
{
|
||||
this.ibanCleared = this.iban.ToUpper().Replace(" ", "").Replace("-", "").Replace(".", "");
|
||||
//Console.WriteLine(ibanCleared);
|
||||
this.ibanSwapped = ibanCleared.Substring(4) + ibanCleared.Substring(0, 4);
|
||||
//Console.WriteLine(ibanSwapped);
|
||||
this.sum = ibanSwapped.Aggregate("", (current, c) => current + (char.IsLetter(c) ? (c - 55).ToString() : c.ToString()));
|
||||
//Console.WriteLine(sum);
|
||||
//this.sum = ibanCleared.Aggregate("", (current, c) => current + (char.IsLetter(c) ? (c - 55).ToString() : c.ToString()));
|
||||
|
||||
var d = decimal.Parse(sum);
|
||||
return ((d % 97) == 1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
IBANNummerPrüfen/Program.cs
Normal file
11
IBANNummerPrüfen/Program.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace IBANNummerPrüfen
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
IbanPrüfung iban = new IbanPrüfung();
|
||||
iban.SetIbanPrüfungEntgegennehmen();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user