using System;
using System.Collections.Generic;
public class Program
{
// first repeated character from a string
public static char GetFirstRepeatedCharacter(string str)
var hashSet = new HashSet<char>();
foreach(var c in str)
if(!hashSet.Add(c))
return c;
}
return '\0';
public static void Main()
Console.WriteLine(GetFirstRepeatedCharacter("abcdef_c"));