public static void Main()
Console.WriteLine("Hello World");
if (FixedMatch("test.txt.log", "*.txt")) {
Console.WriteLine("1Match");
Console.WriteLine("1No Match");
if (Match("test.txt.log", "*.txt")) {
Console.WriteLine("2Match");
Console.WriteLine("2No Match");
private static bool Match(string s1, string s2)
if (s2 == "*" || s1 == s2) return true;
if (s1 == "") return false;
if (s1[0] == s2[0] || s2[0] == '?') return Match(s1.Substring(1), s2.Substring(1));
if (s2[0] == '*') return Match(s1.Substring(1), s2) || Match(s1, s2.Substring(1));
private static bool FixedMatch(string s1, string s2)
if (s2 == "*" || s1 == s2) return true;
if (s1 == "" || s2 == "") return false;
if (s1[0] == s2[0] || s2[0] == '?') return FixedMatch(s1.Substring(1), s2.Substring(1));
if (s2[0] == '*') return FixedMatch(s1.Substring(1), s2) || FixedMatch(s1, s2.Substring(1));