input: Write a function to convert the given Python program to a C# program. The function should accurately replicate the original functionality and adhere to C# syntax.
  assert convert_to_csharp(def power(x, y):\n    if y == 0:\n        return 1\n    else:\n        return x * power(x, y - 1)) == "public int Power(int x, int y)\n{\n    if (y == 0)\n    {\n        return 1;\n    }\n    else\n    {\n        return x * Power(x, y - 1);\n    }\n}"
  assert convert_to_csharp(def factorial(n):\n    if n == 0:\n        return 1\n    else:\n        return n * factorial(n - 1)) == "public int Factorial(int n)\n{\n    if (n == 0)\n    {\n        return 1;\n    }\n    else\n    {\n        return n * Factorial(n - 1);\n    }\n}"
output: def convert_to_csharp(python_code):
      import re
      function_name = re.search(r'def (\w+)\(', python_code).group(1)
      csharp_code = f"public int {function_name.capitalize()}(int "
      params = re.search(r'def \w+\((.*?)\)', python_code).group(1)
      csharp_code += params.replace(', ', ', int ') + ")\n{\n"
      body = re.sub(r'return (\w+)\(', r'return \1(', python_code)
      body = re.sub(r'def \w+\(.*?\):\n', '', body)
      body = body.replace('if ', 'if (').replace(':\n', ')\n    {\n').replace('else:\n', '    }\n    else\n    {\n')
      body = body.replace('return ', 'return ').replace('\n', ';\n').replace(';\n    }', '\n    }')
      csharp_code += body + "\n}"
      return csharp_code