'System.Windows.Forms.FolderBrowserDialog' is a type not a namespace

后端 未结 6 406
眼角桃花
眼角桃花 2020-12-22 02:29

It is possible that I\'m missing something very obvious but now I can not see now. I have the reference to System.Windows.Forms and I have the next using<

相关标签:
6条回答
  • 2020-12-22 03:09

    That's because it IS a type, not a namespace. You don't reference the types in the using statements, only the namespaces. This isn't Java.

    0 讨论(0)
  • 2020-12-22 03:11

    It seems that System.Windows.Forms.FolderBrowserDialog is not a namespace but rather a class that is part of the namespace System.Windows.Forms.

    The *.Forms.FolderBrowserDialog is a class located within that namespace. Here is an example of how it should be used. (example is at the bottom of the page)

    0 讨论(0)
  • 2020-12-22 03:15

    Right now you're trying to import FolderBrowserDialog but it's actually an object. To use it you remove:

    using System.Windows.Forms.FolderBrowserDialog;
    

    And instead reference is by creating an object like this...

    FolderBrowserDialog x = new FolderBrowserDialog();
    
    0 讨论(0)
  • 2020-12-22 03:21

    System.Windows.Forms.FolderBrowserDialog is a class, is'nt a namespace to using it, clear that line.

    0 讨论(0)
  • 2020-12-22 03:25

    You cannot do

    using System.Windows.Forms.FolderBrowserDialog;
    

    as it is a type and not a namespace. The namespace it belongs to is System.Windows.Forms. Remove this line and if you want to instantiate a FolderBrowserDialog and just make sure you have the line

    using System.Windows.Forms;
    

    and make a FolderBrowserDialog like so:

    var fbd = new FolderBrowserDialog();
    

    All this is in contrast to Java, where you import types not use namespaces, which is where you may be going wrong - in Java you would do something like:

    import System.Windows.Forms.FolderBrowserDialog;
    

    and then be able to use it.

    0 讨论(0)
  • 2020-12-22 03:29

    The using directive imports namespaces, not types.

    Once you import System.Windows.Forms, you can use all of the types inside of it, including FolderBrowserDialog.

    0 讨论(0)
提交回复
热议问题