Tag: C#的

使用C ++文件stream(fstream),你如何确定文件的大小?

我确定我刚刚在手册中错过了这个,但是如何从fstream头文件中使用C ++的istream类来确定文件的大小(以字节为单位)?

为什么我的日志在std命名空间中?

在下面的代码中,我定义了一个简单的logfunction。 main我尽量不要打电话。 我打电话std::log 。 不过,我自己的log被称为; 我看到“login” 在屏幕上。 有谁知道为什么? 我使用G ++ 4.7和clang ++ 3.2。 #include <iostream> #include <cmath> double log(const double x) { std::cout << "log!\n"; return x; } int main(int argc, char *argv[]) { std::log(3.14); return 0; }

为什么不是STL映射的运算符常量?

举个例子,为了这个问题: void MyClass::MyFunction( int x ) const { std::cout << m_map[x] << std::endl } 这将不会编译,因为[]运算符是非常量。 这是不幸的,因为[]语法看起来很干净。 相反,我必须做这样的事情: void MyClass::MyFunction( int x ) const { MyMap iter = m_map.find(x); std::cout << iter->second << std::endl } 这一直困扰着我。 为什么[]运算符是非常量?

HashSet如何比较元素的相等性?

我有一个IComparable类: public class a : IComparable { public int Id { get; set; } public string Name { get; set; } public a(int id) { this.Id = id; } public int CompareTo(object obj) { return this.Id.CompareTo(((a)obj).Id); } } 当我将这个类的对象列表添加到散列集时: a a1 = new a(1); a a2 = new a(2); HashSet<a> ha = new HashSet<a>(); ha.add(a1); […]

检测使用C#更改的活动窗口而不进行轮询

每当当前活动窗口改变时,如何调用callback函数。 我已经看到了如何使用CBTProc完成。 但是,全局事件并不容易与托pipe代码挂钩。 我有兴趣find一种不需要轮询的方式。 我更喜欢事件驱动的方法。 问候

如何仅使用OpenGL方法绘制文本?

我没有select使用除opengl方法以外(即glxxx()方法())。 我只需要使用gl方法绘制文本。 读完红皮书后,我明白,只有通过glBitmap()方法才有可能。 如果这是唯一可能的方法,那么任何人都可以帮助我所有字符的像素数组信息。 有没有其他的方式来绘制文字?

将HTMLstring转换为图像

我有一个持有HTML标记的stringvariables。 这个HTML标记基本上代表了电子邮件的内容。 现在我想从这个实际上包含HTML标记的string内容创build一个图像。 我不想通过写入这些内容来创buildHTML文件。 我只是想使用这个string创build一个图像文件。 这是我有: string emailBody="<html><head></head><body><p>This is my text<p>…</body</html>" 如何从这个emailBodystring内容创build一个图像?

如何使用javascript调用ASP.NET c#方法

有谁知道如何调用服务器端的C#方法使用JavaScript? 我需要做的是停止导入,如果select取消或继续导入,如果select好。 我正在使用visual studio 2010和c#作为我的编程语言 这是我的代码: private void AlertWithConfirmation() { Response.Write( "<script type=\"text/javascript\">" + "if (window.confirm('Import is currently in progress. Do you want to continue with importation? If yes choose OK, If no choose CANCEL')) {" + "window.alert('Imports have been cancelled!');" + "} else {" + "window.alert('Imports are still in progress');" + "}" + "</script>"); […]

WPF将列表框绑定到一个枚举,显示描述属性

有没有可能使用ObjectDataProvider方法绑定列表框到一个枚举,并以某种方式来显示描述属性? 如果是的话,怎么会这样做…?

得到最接近的一条线

我想有一个直接的C#函数来获得最近点(从点P)到线段AB。 抽象函数可能看起来像这样。 我已经通过search,但没有find一个可用(由我)的解决scheme。 public Point getClosestPointFromLine(Point A, Point B, Point P);