input: Write a function to convert a given Python program to a C# program. If the input is a Python function, return the equivalent C# function. If the input is anything else, return an error message.
  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 hello_world():\n    print('Hello, World!')")=="public void HelloWorld()\n{\n    Console.WriteLine(\"Hello, World!\");\n}"
  assert convert_to_csharp("some random text")=="Input is not a valid Python function"
  assert convert_to_csharp("")=="Input is not a valid Python function"
  assert convert_to_csharp("def foo(): return")=="public void Foo()\n{\n    return;\n}"
output: def convert_to_csharp(py_code):
      if not py_code.strip().startswith("def "):
          return "Input is not a valid Python function"
      
      try:
          tree = ast.parse(py_code)
          if len(tree.body) != 1 or not isinstance(tree.body[0], ast.FunctionDef):
              return "Input is not a valid Python function"
          
          func_def = tree.body[0]
          func_name = func_def.name
          args = [arg.arg for arg in func_def.args.args]
          return_type = "void"
          
          for stmt in func_def.body:
              if isinstance(stmt, ast.Return):
                  if stmt.value is not None:
                      return_type = "int"
                      break
          
          csharp_args = ", ".join([f"int {arg}" for arg in args])
          csharp_body = ""
          
          for stmt in func_def.body:
              if isinstance(stmt, ast.Return):
                  if stmt.value is None:
                      csharp_body += "    return;\n"
                  else:
                      csharp_body += f"    return {ast.unparse(stmt.value)};\n"
              elif isinstance(stmt, ast.Expr) and isinstance(stmt.value, ast.Call) and isinstance(stmt.value.func, ast.Name) and stmt.value.func.id == "print":
                  csharp_body += f"    Console.WriteLine({ast.unparse(stmt.value.args[0])});\n"
              elif isinstance(stmt, ast.If):
                  csharp_body += f"    if ({ast.unparse(stmt.test)})\n    {{\n"
                  for sub_stmt in stmt.body:
                      if isinstance(sub_stmt, ast.Return):
                          csharp_body += f"        return {ast.unparse(sub_stmt.value)};\n"
                  csharp_body += "    }\n    else\n    {\n"
                  for sub_stmt in stmt.orelse:
                      if isinstance(sub_stmt, ast.Return):
                          csharp_body += f"        return {ast.unparse(sub_stmt.value)};\n"
                  csharp_body += "    }\n"
          
          return f"public {return_type} {func_name.capitalize()}({csharp_args})\n{{\n{csharp_body}}}"
      
      except SyntaxError:
          return "Input is not a valid Python function"