小编Mas*_*oud的帖子

C#中标准I/O的非阻塞读取

我想从控制台获得非阻塞读取功能.我如何用C#编写?

c# console-application nonblocking

22
推荐指数
2
解决办法
2万
查看次数

从C#中的hashset中检索对象

可能重复:
为什么我不能在没有枚举的情况下从HashSet中检索项目?

我需要向Set添加很多对象.我应该非常快速地检索它们.我知道的唯一方法是使用哈希.但是C#中的HashSet类不包含任何"Get"方法.字典类没有用,因为在字典中查找对象非常耗时.

c# hash

15
推荐指数
1
解决办法
2万
查看次数

Eclipse - C++ hello world项目的错误

我使用的是64位Winodws 7.我已下载CDT Eclipse并已下载MinGW.之后,我创建了一个c ++ hello world项目.这是代码:

#include <iostream>
using namespace std;

int main() {
    cout << "!!!Hello World!!!" << endl; // This is supposed to print "Hello World!!!"
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是当我想运行它时,会弹出这个错误:"启动失败Binary not found."

任何帮助都会受到高度欢迎.

c++ eclipse binary windows-7

13
推荐指数
1
解决办法
3万
查看次数

C#中的字典类 - 两个对象的等价

我有一个名为Class1的类我覆盖它的Equals函数现在我有一个Dictionary的实例我添加了一个名为OBJ1的Class1实例.我有另一个名为OBJ2的Class1实例.对于OBJ1.Equals(OBJ2),代码返回true.但我在字典中找不到OBJ2.

这是伪代码

Class1 OBJ1 = new Class1(x, y, z);
Class1 OBJ2 = new Class1(a, b, c);
Dictionary<Class1, int> dic1 = new Dictionary<Class1, int>();
dic1.Add(OBJ1, 3);
OBJ1.Equals(OBJ2) -------------> return true
Dictionary.ContainsKey(OBJ2) --------------> return false
Run Code Online (Sandbox Code Playgroud)

为什么会这样?任何帮助都会受到高度欢迎

c# dictionary equals

4
推荐指数
2
解决办法
4973
查看次数

两个不同计算机中的奇怪RoundTo函数行为

问题很简单而且很奇怪!我在Delphi中编写了一个程序并使用了roundto函数.在一台计算机中,1.5舍入到2,在另一台计算机中,它舍入为1.这怎么可能发生?

PS:代码------> Roundto(1.5,0)

PS 2:似乎需要更多信息,所以我发布更详细的细节.我写了一个程序.他们输入了两个数字:a = 7231.76 b = 3556.71现在他们可以输入第三个数字c如果c> = a - b但我的代码中的确切形式是

`roundto(c, -1) >= roundto(a, -1) - roundto(b, -1)`
`roundto(a, -1) = 7231.8`
`roundto(b, -1) = 3556.7`
Run Code Online (Sandbox Code Playgroud)

所以

`roundto(a, -1) - roundto(b, -1) = 3675.1`
Run Code Online (Sandbox Code Playgroud)

他们进来了

`c = 3675.05`
Run Code Online (Sandbox Code Playgroud)

我追踪了这个程序.它说的是一台计算机,round(c, -1) = 3675.1而另一台计算机则说round(c, -1) = 3675.0

delphi rounding

3
推荐指数
1
解决办法
3371
查看次数

功能无法访问

我有

// file BoardInitializer.h
#include <stdio.h>
#include <tchar.h>
#include <string>
#include <iostream>

using namespace std;
class BoardInitializer
{
    static int *beginBoard;
    static int *testBoard;
    static void testBoardInitialize();
}



// file mh.cpp
#include "BoardInitializer.h"

int main(int argc, char* argv[])
{
    BoardInitializer.testBoardInitialize();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我实施BoardInitializer::testBoardInitializemh.cpp.但我收到错误"功能无法访问".怎么了?

c++

3
推荐指数
3
解决办法
9572
查看次数

在c ++中两次的差异

起初我有时间

time_t t1 = time(0) 
Run Code Online (Sandbox Code Playgroud)

(这是获得当前时间的权利吗?)然后

time_t t2 = time(0)
Run Code Online (Sandbox Code Playgroud)

现在我希望找到t1和t2之间的差异,以毫秒为单位我搜索了很多,但它没有用.很多铸造问题,无法将其更改为毫秒,感谢您的帮助

c++ time

3
推荐指数
2
解决办法
2万
查看次数

在 C# 中为线程指定一个特殊的 cpu

我有 2 个线程。我想告诉其中一个在第一个 cpu 上运行,第二个在第二个 cpu 上运行,例如在一台有两个 cpu 的机器上。我怎样才能做到这一点?

这是我的代码

UCI UCIMain = new UCI();
Thread UCIThread = new Thread(new ThreadStart(UCIMain.main));
UCIThread.Priority = ThreadPriority.BelowNormal;
UCIThread.Start();
Run Code Online (Sandbox Code Playgroud)

并且该类肯定UCI有一个名为main. 例如,我想在第一个处理器中设置这个线程

c# cpu multithreading

3
推荐指数
1
解决办法
916
查看次数

C#和C++中字符串操作的不同基准

我在C++中有两个非常简单的代码,在c#中有C#

for (int counter = 0; counter < 100000; counter ++)
{
    String a = "";
    a = "xyz";
    a = a + 'd';
    a = a + 'c';
    a = a + 'h';
}
Run Code Online (Sandbox Code Playgroud)

在c ++中

for (int counter = 0; counter < 100000; counter ++)
{
    string a = "";
    a.append("xyz");
    a = a + 'd';
    a = a + 'c';
    a = a + 'h';
}
Run Code Online (Sandbox Code Playgroud)

奇怪的是c#代码执行时间比c ++代码少1/20.你能帮我找一下为什么会这样吗?以及如何更改我的c ++代码以加快速度.

c# c++ string

2
推荐指数
1
解决办法
462
查看次数

64 位 gethashcode 是否可用于对象?

我正在使用字典,我想覆盖GetHashCodeKey的功能。但我需要一个 64 位哈希码。

有什么解决办法吗?

c# 64-bit hashcode

2
推荐指数
1
解决办法
1883
查看次数