43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DoppelteBuchstaben
|
|
{
|
|
internal class DuplicateChars
|
|
{
|
|
private string _text;
|
|
public bool ContainsDuplicateChars(string text)
|
|
{
|
|
for (int i = 0; i < text.Length; i++)
|
|
{
|
|
for (int j = i + 1; j < text.Length; j++)
|
|
{
|
|
if (text[i] == text[j])
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
public string RemoveDuplicateChars(string text)
|
|
{
|
|
for (int i = 0; i < text.Length; i++)
|
|
{
|
|
for (int j = i + 1; j < text.Length; j++)
|
|
{
|
|
if (text[i] == text[j])
|
|
{
|
|
this._text = text.Remove(j);
|
|
return this._text;
|
|
}
|
|
}
|
|
}
|
|
return text;
|
|
}
|
|
}
|
|
}
|