'System.Windows.Forms.FolderBrowserDialog'是一个类型不是一个命名空间 [英] 'System.Windows.Forms.FolderBrowserDialog' is a type not a namespace
问题描述
这可能是我想的东西很明显的,但现在我不能看到现在。我有参考 System.Windows.Forms的
和我有一个使用
类:
使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用System.Text;使用System.Windows
;使用System.Windows.Controls的
;
使用System.Windows.Data;使用System.Windows.Documents
;
使用System.Windows.Input;使用System.Windows.Media
;
使用System.Windows.Media.Imaging;
使用System.Windows.Navigation;使用System.Windows.Shapes
;
:使用System.IO;
$ B $使用System.Windows.Forms的B:
使用System.Windows.Forms.FolderBrowserDialog;
但是编译器总是给我的下一个错误:
错误CS0138 :一个使用命名空间指令只能应用于
命名空间; System.Windows.Forms.FolderBrowserDialog是一种不是
命名空间
块引用>
解决方案您不能做
使用System.Windows.Forms.FolderBrowserDialog;
,因为它的是的一个类型,而不是一个命名空间。它属于命名空间是
System.Windows.Forms的
。删除此行,如果你想实例化一个的FolderBrowserDialog
,只是确保你有行使用System.Windows.Forms的;
和使
的FolderBrowserDialog
像这样:VAR FBD =新的FolderBrowserDialog();
这一切都是在对比Java中,在那里你的导入类型的没有的使用命名空间的,这就是你可能会错误 - 在Java中,你会做这样的事情:
进口System.Windows.Forms.FolderBrowserDialog;
然后就可以使用它。
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 nextusing
classes:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.IO; using System.Windows.Forms; using System.Windows.Forms.FolderBrowserDialog;
But the compiler always give to me the next error:
error CS0138: A using namespace directive can only be applied to namespaces; 'System.Windows.Forms.FolderBrowserDialog' is a type not a namespace
解决方案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 aFolderBrowserDialog
and just make sure you have the lineusing 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.
这篇关于'System.Windows.Forms.FolderBrowserDialog'是一个类型不是一个命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!