小编use*_*116的帖子

使用bind1st和bind2nd与transform的问题

我认为C++ 0x绑定要好得多,但我想在使用C++ 0x绑定之前理解旧的bind1st和2st:

struct AAA
{
    int i;
};

struct BBB
{
    int j;
};

// an adaptable functor.
struct ConvertFunctor : std::binary_function<const AAA&, int, BBB>
{
    BBB operator()(const AAA& aaa, int x)
    {
        BBB b;
        b.j = aaa.i * x;
        return b;
    }
};

BBB ConvertFunction(const AAA& aaa, int x)
{
    BBB b;
    b.j = aaa.i * x;
    return b;
}

class BindTest
{
public:
    void f()
    {
        std::vector<AAA> v;
        AAA a;
        a.i = 0;
        v.push_back(a);
        a.i = 1; …
Run Code Online (Sandbox Code Playgroud)

c++ stl c++11

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

组合框输入事件 WPF

每当Enter在组合框内按下时,我都需要触发一个事件。这是一个 WPF C# 4.0 控件,我无法找到特定的事件处理程序来执行此操作。我想我错过了一些东西,因为这似乎是包含在内的东西。是否有预先存在的代码来完成此任务?

我也试过:

private void comboBox1_SelectionChanged(
    object sender,
    SelectionChangedEventArgs e)
{
     if (e.Equals(Key.Enter))
     {
         // Do Something
     }
}
Run Code Online (Sandbox Code Playgroud)

c# wpf combobox c#-4.0

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

使用foreach循环检索GroupBox中的TextBox

我有十个组合框WinForm.每个组框包含10个文本框,我已定义每个TextBox名称.如何使用foreach循环获取每个文本框?

.net c# winforms

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

使用正则表达式比较两个软件版本号

如何使用Regex查找最新版本号?例如

3.0.0.0和3.1.0.0

4.0.1.0和4.0.1.2

问候

庵埠

c# regex

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

根据c#中创建的日期搜索文件

我有这个功能,我用来读取目录并获取具有特定搜索模式的文件.有没有办法根据创建日期或修改日期使用搜索模式?

public static List<FileInfo> GetFileList(string fileSearchPattern, string rootFolderPath)
{
    DirectoryInfo rootDir = new DirectoryInfo(rootFolderPath);

    List<DirectoryInfo> dirList = new List<DirectoryInfo>(
        rootDir.GetDirectories("*", SearchOption.AllDirectories));
    dirList.Add(rootDir);

    List<FileInfo> fileList = new List<FileInfo>();

    foreach (DirectoryInfo dir in dirList)
    {
        fileList.AddRange(
            dir.GetFiles(fileSearchPattern, SearchOption.TopDirectoryOnly));
    }

    return fileList;
}
Run Code Online (Sandbox Code Playgroud)

.net c#

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

获取属性列表(通过反射)时,我们可以排除ReadOnly吗?

这段代码将为我们提供类的所有属性:

Dim myPropertyInfo As PropertyInfo()
     = myType.GetProperties((BindingFlags.Public Or BindingFlags.Instance))
Run Code Online (Sandbox Code Playgroud)

或者在C#中:

PropertyInfo[] myPropertyInfo
     = myType.GetProperties(BindingFlags.NonPublic|BindingFlags.Instance);
Run Code Online (Sandbox Code Playgroud)

但有没有办法获得定义为ReadOnly的属性?

或者,同样地,排除ReadOnly属性?

.net reflection

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

WPF和SilverLight设计值得学习

对于使用WPF或Silverlight(xaml代码)进行项目的开发人员来说,是否可以尝试学习一些设计(基础知识)并处理混合?因为在法国没有太多混合专业(与photoshop用户相比),混合设计师的价格/天非常高.

我确信我不是没有艺术家,但学习与纯代码不同的东西可能会很有趣/有趣.所以我的问题主要是设计师或开发人员必须学习一些设计,对定制设计来说难吗?

silverlight wpf xaml expression-blend

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

无法将IEnumerable <Triangle>传递给正在寻找IEnumerable <IShape>的函数

我有一组对象:

 IEnumerable<Triangle>
Run Code Online (Sandbox Code Playgroud)

这些对象支持一个接口IShape但是我在尝试将其传递给要求的函数时遇到错误:

 IEnumerable<IShape>
Run Code Online (Sandbox Code Playgroud)
  1. 为什么我不能通过这个?
  2. 是否有任何解决方法将一个转换为另一个以使其工作?

c# ienumerable interface .net-3.5

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

警告:隐式声明函数

我在C编程,我的gcc编译器在我的函数调用中给出了以下警告 mySedondFile.c:

implicit declaration of function 'func'
Run Code Online (Sandbox Code Playgroud)

函数原型声明myfile.h为:

void  func(char*);
Run Code Online (Sandbox Code Playgroud)

函数定义在 myfile.c

void  func(char*x);
Run Code Online (Sandbox Code Playgroud)

mySecondFile.c 包含:

#include "myfile.h"

func("Hello");
Run Code Online (Sandbox Code Playgroud)

我想知道为什么这会抱怨.

c

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

C++中的Singleton多线程代码

我对使用C++中的Singleton和多线程编程有疑问之后您可以看到Singleton类的示例代码,其中包含名为shared的变量.

我创建了1000个线程来修改(+1)我的Singleton全局实例的变量.共享的最终值是1000但我希望这个值低于1000,因为我没有保护这个变量的并发性.

代码是否真的是线程安全的,因为类是Singleton或它恰好是幸运的,值是1000但它可以完全小于1000?

#include <iostream>
using namespace std;

class Singleton {
private:
    Singleton() {shared = 0;};
    static Singleton * _instance;
    int shared;

public:
    static Singleton* Instance();
    void increaseShared () { shared++; };
    int getSharedValue () { return shared; };
};

// Global static pointer used to ensure a single instance of the class.
Singleton* Singleton::_instance = NULL;

Singleton * Singleton::Instance() {
    if (!_instance) { 
        _instance = new Singleton;
    }

    return _instance;
}

void * myThreadCode (void * param) {
    Singleton …
Run Code Online (Sandbox Code Playgroud)

c++ concurrency singleton multithreading

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