#39;System.Windows.Forms.FolderBrowserDialog#39; is a type not a namespace(System.Windows.Forms.FolderBrowserDialog 是一种类型而不是命名空间)
问题描述
我可能遗漏了一些非常明显的东西,但现在我看不到了.我有对 System.Windows.Forms
的引用,并且我有下一个 using
类:
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
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:
错误 CS0138:使用命名空间指令只能应用于命名空间;'System.Windows.Forms.FolderBrowserDialog' 是一种类型而不是命名空间
error CS0138: A using namespace directive can only be applied to namespaces; 'System.Windows.Forms.FolderBrowserDialog' is a type not a namespace
推荐答案
你做不到
using System.Windows.Forms.FolderBrowserDialog;
因为它是一个类型而不是一个命名空间.它所属的命名空间是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;
并像这样制作一个 FolderBrowserDialog
:
var fbd = new FolderBrowserDialog();
<小时>
所有这一切都与 Java 形成对比,在 Java 中您导入类型而不是使用命名空间,这可能是您出错的地方 - 在 Java 中您会执行以下操作:
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;
然后就可以使用了.
这篇关于'System.Windows.Forms.FolderBrowserDialog' 是一种类型而不是命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:'System.Windows.Forms.FolderBrowserDialog' 是一种类型而不是命名空间


基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01