“Thread是用作类型的命名空间”。错误。 [英] "Thread is a namespace used as type" error.

查看:103
本文介绍了“Thread是用作类型的命名空间”。错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码给出错误Thread是用作类型的命名空间

Following code giving the error "Thread is a namespace used as type"

Printer p = new Printer();
ThreadStart ts = new ThreadStart(p.printSeries);
Thread th = new Thread(ts);



你能告诉我什么是问题??


could you tell me please what is the problem??

推荐答案

这就是我的假设!

您的命名空间称为线程。

请将其重命名为例如ThreadTest
This is what I assumed!
Your namespace is called "Thread".
Please rename it to e.g. ThreadTest


在你的评论中,有这一行:

In your comment, there is this line:
namespace Thread



这意味着您调用了程序的命名空间 Thread 。但是在 Thread th = new Thread(ts); 行,编译器认为你定位命名空间 Thread ,而不是类 Thread 。您可以更改名称空间的名称来解决它。


This means that you called the namespace of your program Thread. But at the Thread th = new Thread(ts); line, the compiler thinks that you target the namespace Thread, not the class Thread. You can change the name of your namespace to solve it.


简单。更改命名空间 -



Simple. Change your namespace -

namespace Thread1
{
class Program
{
...





Thread是系统定义的类。将命名空间更改为其他内容。



希望有所帮助:)



Thread is a system defined class. Change the namespace to something else.

Hope that helps :)


这篇关于“Thread是用作类型的命名空间”。错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆