Tag: C#的

Round()在C ++中哪里?

复制: round()for C ++中的float 我使用的VS2008,我已经包括math.h,但我仍然无法find一个循环的函数。 它存在吗? 我在谷歌上看到了一堆“添加0.5并投射到整数”的解决scheme。 这是最佳做法吗?

为什么open()用错误的权限创build我的文件?

我正在尝试从文件中读取一些文本,并使用open() , read()和write()将其写入另一个文本。 这是我open()的文件写入(我想创build一个新的文件,并写入它): fOut = open ("test-1", O_RDWR | O_CREAT | O_SYNC); 这是设置文件权限的东西,我根本不明白。 这是ls -l的输出: ———T 1 chaitanya chaitanya 0 2010-02-11 09:38 test-1 即使读取权限被locking。 我试图寻找这个,但无法find任何东西。 奇怪的是, write()仍然成功地写入数据到文件。 另外,如果我执行“chmod 777 test-1”,事情就会重新开始。 有人可以让我知道我公开的电话中哪里出错吗? 谢谢! 为了您的参考,我已经粘贴了下面的完整程序: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> int main () { char buffer[512], ch; int fIn, fOut, i; ssize_t bytes; […]

testing在c#中的字典之间的平等

假设字典键和值有正确实现的equals和hash方法,testing两个字典相等的最简洁和有效的方法是什么? 在这种情况下,如果两个字典包含相同的一组密钥(顺序不重要),则说它们是相等的,并且对于每个这样的密钥,它们都同意这个值。 这里有一些我想出来的方法(可能还有更多): public bool Compare1<TKey, TValue>( Dictionary<TKey, TValue> dic1, Dictionary<TKey,TValue> dic2) { return dic1.OrderBy(x => x.Key). SequenceEqual(dic2.OrderBy(x => x.Key)); } public bool Compare2<TKey, TValue>( Dictionary<TKey, TValue> dic1, Dictionary<TKey, TValue> dic2) { return (dic1.Count == dic2.Count && dic1.Intersect(dic2).Count(). Equals(dic1.Count)); } public bool Compare3<TKey, TValue>( Dictionary<TKey, TValue> dic1, Dictionary<TKey, TValue> dic2) { return (dic1.Intersect(dic2).Count(). Equals(dic1.Union(dic2).Count())); }

在c ++中将非const转换为const

我知道你可以使用const_cast将一个const转换为非const 。 但是,如果你想将非const为const你应该使用什么?

在成员variables的C#命名约定

我在这里看到了一个build议,不要用private/public成员variables的名字来区分,只是以第一个字符为例。 例如: private string logFileName; public string LogFileName { get { return logFilename …. 和: private System.Windows.Forms.MainMenu mainMenu; 和: DialogResult dialogResult = this.saveConfigFileDialog.ShowDialog(); 和: public Version Version { get; set; } 和: private void CheckPollingType(PollingType pollingType) { 那么,我听错了吗? 这些命名约定有什么问题吗? 如果是的话,那么有什么更好的办法呢? 链接,引用是一个加号。 谢谢。

如何将枚举types绑定到DropDownList?

如果我有以下枚举 public enum EmployeeType { Manager = 1, TeamLeader, Senior, Junior } 我有DropDownList,我想要将此EmployeeType枚举绑定到DropDownList,有没有办法做到这一点?

C ++终止调用没有一个活动的exception

我得到一个C ++线程错误: terminate called without an active exception Aborted 这里是代码: #include <queue> #include <thread> #include <mutex> #include <condition_variable> template<typename TYPE> class blocking_stream { public: blocking_stream(size_t max_buffer_size_) : max_buffer_size(max_buffer_size_) { } //PUSH data into the buffer blocking_stream &operator<<(TYPE &other) { std::unique_lock<std::mutex> mtx_lock(mtx); while(buffer.size()>=max_buffer_size) stop_if_full.wait(mtx_lock); buffer.push(std::move(other)); mtx_lock.unlock(); stop_if_empty.notify_one(); return *this; } //POP data out of the buffer […]

C#是否支持可变数量的参数,以及如何?

C#是否支持可变数量的参数? 如果是,C#如何支持variablesno的参数? 什么是例子? variables参数如何有用? 编辑1 :它有什么限制? 编辑2 :问题不是可选参数,而是variables参数

将JObject转换成Dictionary <string,object>。 可能吗?

我有一个Web API方法,接受一个任意的JSON负载到一个JObject属性。 因此,我不知道会发生什么,但我仍然需要将其转换为.NETtypes。 我想有一个词典,所以我可以处理它,无论如何我想。 我search了很多,但无法find任何东西,并最终开始了一个混乱的方法来做这种转换,按键,价值的价值。 有没有简单的方法来做到这一点? input – > JObject person = new JObject( new JProperty("Name", "John Smith"), new JProperty("BirthDate", new DateTime(1983, 3, 20)), new JProperty("Hobbies", new JArray("Play footbal", "Programming")), new JProperty("Extra", new JObject( new JProperty("Foo", 1), new JProperty("Bar", new JArray(1, 2, 3)) ) ) 谢谢!

带有参数的基类构造函数的inheritance

简单的代码: class foo { private int a; private int b; public foo(int x, int y) { a = x; b = y; } } class bar : foo { private int c; public bar(int a, int b) { c = a * b; } } Visual Studio抱怨“酒吧”的构造函数: 错误CS7036没有给出的参数对应于'foo.foo(int,int)'所需的forms参数'x'。 什么??