using System;
using System.Linq;
public class Test
{
public static void Main() {
string[] tests = { "a", 1.ToString(), "321", "xyz" };
foreach (var test in tests) {
Console.WriteLine(test.ToChar());
}
}
}
public static class StringExtensions {
public static char ToChar(this string value) {
if (string.IsNullOrEmpty(value)) throw new ArgumentException();
return value.First();
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTGlucTsKCnB1YmxpYyBjbGFzcyBUZXN0CnsKICBwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpIHsKICAgIHN0cmluZ1tdIHRlc3RzID0geyAiYSIsIDEuVG9TdHJpbmcoKSwgIjMyMSIsICJ4eXoiIH07CiAgICBmb3JlYWNoICh2YXIgdGVzdCBpbiB0ZXN0cykgewogICAgICBDb25zb2xlLldyaXRlTGluZSh0ZXN0LlRvQ2hhcigpKTsKICAgIH0KICB9Cn0KCnB1YmxpYyBzdGF0aWMgY2xhc3MgU3RyaW5nRXh0ZW5zaW9ucyB7CiAgcHVibGljIHN0YXRpYyBjaGFyIFRvQ2hhcih0aGlzIHN0cmluZyB2YWx1ZSkgewogICAgaWYgKHN0cmluZy5Jc051bGxPckVtcHR5KHZhbHVlKSkgdGhyb3cgbmV3IEFyZ3VtZW50RXhjZXB0aW9uKCk7CiAgICByZXR1cm4gdmFsdWUuRmlyc3QoKTsKICB9Cn0=