dotnet ubuntu14.04 错误 CS0246:找不到类型或命名空间名称 'Thread'
dotnet ubuntu14.04 error CS0246: The type or namespace name 'Thread' could not be found
我按照“http://dotnet.github.io/getting-started/”上的说明在 ubuntu.14.04-x64 上安装了 Dotnet。然后我写了一个简单的线程代码,
using System;
using System.Threading;
namespace mythread
{
public class threader
{
public static void thread1()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine("Thread1 value: {0}.", i);
}
}
public static void thread2()
{
for (int j = 0; j < 10; ++j)
{
Console.WriteLine("Thread2 value: {0}.", j);
}
}
}
public class class1
{
public static void Main()
{
ThreadStart t1 = new ThreadStart(threader.thread1);
ThreadStart t2 = new ThreadStart(threader.thread2);
Thread tr1 = new Thread(t1);
Thread tr2 = new Thread(t2);
tr1.Start();
tr2.Start();
}
}
}
在 运行 这段代码之后我遇到了错误
"error CS0246: The type or namespace name 'Thread' could not be found (are you missing a using directive or an assembly reference?)"。
谁能帮我解决一下?
我的project.json是
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23811"
},
"frameworks": {
"dnxcore50": {
"dependencies": {
"System.Threading": "4.0.11-rc2-23811",
"System.Threading.Tasks": "4.0.11-rc2-23811"
}
}
},
"configurations": {
"Debug": {
"compilationOptions": {
"define": ["DEBUG", "TRACE"]
}
},
"Release": {
"compilationOptions": {
"define": ["RELEASE", "TRACE"],
"optimize": true
}
}
}
}
提前致谢。
您需要在 project.json
中引用 System.Threading.Thread
我按照“http://dotnet.github.io/getting-started/”上的说明在 ubuntu.14.04-x64 上安装了 Dotnet。然后我写了一个简单的线程代码,
using System;
using System.Threading;
namespace mythread
{
public class threader
{
public static void thread1()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine("Thread1 value: {0}.", i);
}
}
public static void thread2()
{
for (int j = 0; j < 10; ++j)
{
Console.WriteLine("Thread2 value: {0}.", j);
}
}
}
public class class1
{
public static void Main()
{
ThreadStart t1 = new ThreadStart(threader.thread1);
ThreadStart t2 = new ThreadStart(threader.thread2);
Thread tr1 = new Thread(t1);
Thread tr2 = new Thread(t2);
tr1.Start();
tr2.Start();
}
}
}
在 运行 这段代码之后我遇到了错误 "error CS0246: The type or namespace name 'Thread' could not be found (are you missing a using directive or an assembly reference?)"。 谁能帮我解决一下?
我的project.json是
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23811"
},
"frameworks": {
"dnxcore50": {
"dependencies": {
"System.Threading": "4.0.11-rc2-23811",
"System.Threading.Tasks": "4.0.11-rc2-23811"
}
}
},
"configurations": {
"Debug": {
"compilationOptions": {
"define": ["DEBUG", "TRACE"]
}
},
"Release": {
"compilationOptions": {
"define": ["RELEASE", "TRACE"],
"optimize": true
}
}
}
}
提前致谢。
您需要在 project.json
System.Threading.Thread