c# identifier expected?

后端 未结 4 2012
余生分开走
余生分开走 2020-12-10 15:41

I am trying to create a program to copy all the files from one directory to another. But I am running in a basic issue. It says indentifier expected when I try to compile on

相关标签:
4条回答
  • 2020-12-10 15:51

    Here is your problem:

    static void RecursiveCopy(origDir, destDir)
    

    You don't specify the types for the parameters, perhaps you intended the following:

    static void RecursiveCopy(string origDir, string destDir)
    

    There are more issues however that I've noticed. It's possible you're still working on these, but from what you've posted:

    • You never call your RecursiveCopy method. Perhaps you meant to call it from Main() instead of declaring an overload with two parameters?

    • You declare two public fields origDir and destDir but then never use them. Instead you create two local variables in RecursiveCopy() and use these instead. Did you intend to create parameters or use the public fields instead?

    • Your copy is not actually true to its name of "recursive".

    0 讨论(0)
  • 2020-12-10 15:56

    cYou are missing the parameter types in the RecursiveCopy method declaration. Just Change

    static void RecursiveCopy(origDir, destDir)
    

    to

    static void RecursiveCopy(String origDir, String destDir)
    

    and all is fine.

    0 讨论(0)
  • 2020-12-10 16:03

    Your method RecursiveCopy has two parameters listed without their types. It should be this:

    static void RecursiveCopy(string origDir, string destDir)
    
    0 讨论(0)
  • 2020-12-10 16:11

    You did not give type identifiers to your argument list here

    static void RecursiveCopy(origDir, destDir)
    

    should be

    static void RecursiveCopy(string origDir, string destDir)
    
    0 讨论(0)
提交回复
热议问题