小编5Yr*_*DBA的帖子

使用Visual Studio 6将Boost从Linux移动到Windows

2年前,我在Linux上用Boost做了一个小程序.现在我想让它在Windows中运行.我发现我的libs文件夹中有几个.a文件.我想知道如何让它在Windows中运行?我是否需要在Windows中构建Boost以获取库或我可以在某处下载?我正在使用Visual Studio 6.

c++ boost visual-studio

4
推荐指数
1
解决办法
453
查看次数

C#,我可以从构造函数中移出字典初始代码吗?

这是我现在的代码.但是我想从构造函数中移出那些"Add".我们能Dictionarynew什么时候初始化吗?或者你有另一个更好的主意.基本上我想定义几个在很多地方使用的字符.

public class User
    {
        public enum actionEnum
        {
            In,
            Out,
            Fail
        }

        public static Dictionary<actionEnum, String> loginAction = new Dictionary<actionEnum, string>();

        public User()
        {
            loginAction.Add(actionEnum.In, "I");
            loginAction.Add(actionEnum.Out, "O");
            loginAction.Add(actionEnum.Fail, "F");


        }
 .....
}
Run Code Online (Sandbox Code Playgroud)

c#

4
推荐指数
1
解决办法
175
查看次数

copy struct包含另一个struct

struct是C#中的值类型.当我们将a分配struct给另一个struct变量时,它将复制值.如果那struct包含另一个struct怎么样?它会自动复制内部的值struct吗?

.net c#

4
推荐指数
1
解决办法
1245
查看次数

write struct data to binary file

I received some data (many times) which are encapsulated inside a struct. what I need to do is write them to a file (binary) to restore the data. how will you do it?

c#

4
推荐指数
1
解决办法
2893
查看次数

使用命令行构建VS安装项目时为什么没有输出?

我在构建机器上安装了Visual Studio 2008,因为我们要构建安装项目来为我们的C#应用​​程序创建MSI安装程序.

从IDE,它工作正常.安装程序按预期创建.

切换到命令行,使用follow命令完成该过程没有任何错误但没有输出(没有创建安装程序)

DevEnv.exe .\\SystemSoftwareInstaller\\SystemSoftwareInstaller.vdproj /build Debug /Out "debugErr.txt"
Run Code Online (Sandbox Code Playgroud)

改变/build/deploy/rebuild无明显差异(没有安装程序创建)

我做错了什么?

.net c# deployment installer

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

如何指定字体属性的通用Map?

我有这个方法jdk1.6抱怨(没有错误只是警告)关于泛型类型参数化没有在Map和...中使用:

public static Font getStrikethroughFont(String name, int properties, int size)
    {
        Font font = new Font(name, properties, size); 

        Map  attributes = font.getAttributes(); 
        attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); 
        Font newFont = new Font(attributes); 
        return newFont;             
    }
Run Code Online (Sandbox Code Playgroud)

然后我改为以下内容:

public static Font getStrikethroughFont2(String name, int properties, int size)
    {
        Font font = new Font(name, properties, size); 

        Map<TextAttribute, ?>  attributes = font.getAttributes(); 
        attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); 
        Font newFont = new Font(attributes); 
        return newFont;             
    }
Run Code Online (Sandbox Code Playgroud)

但是

attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); 
Run Code Online (Sandbox Code Playgroud)

声明不再有效.

TextAttribute.STRIKETHROUGH_ON 是一个布尔值.

如何在上述方法中使用Generic Type功能?我查看了核心Java书籍,但未找到答案.有人可以帮帮我吗?

java generics

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

为什么没有编译错误的数组定义具有非常量值?

我以为我应该得到allData的以下char数组定义的编译错误:

void MyClass::aMethod(const char* data, int size)
{
   int headerSize = 50;
   MyHeader header;
   //size is not constant and unknown at compile time
   char allData[size + headerSize]; //<<<<<==== should not allowed!! but not error??
   memcpy(allData, &header, headerSize);
   memcpy(allData + headerSize, data, size);
   ....
}
Run Code Online (Sandbox Code Playgroud)

为什么?它会产生运行时错误吗?

c++ arrays

4
推荐指数
1
解决办法
213
查看次数

为什么这个dos命令在python中不起作用?

我尝试将一些dos命令从我的批处理文件移动到python但是得到此错误,文件名,目录名或卷标语法不正确,对于以下语句.

subprocess.Popen('rd /s /q .\ProcessControlSimulator\bin', shell=True, 
                  stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Run Code Online (Sandbox Code Playgroud)

如果我只是将dos命令复制到窗口控制台,它的工作原理.os.getcwd()给了我预期的工作目录.

我的问题是:1.为什么?2.如何避免?我是否需要获取当前工作目录并为该命令构造一个抽象路径?怎么做?

谢谢

python subprocess

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

C#ISerializable问题

我打算用序列化做克隆.我必须让我的课程ISerializable.但是它的超级类和所有引用的变量类呢?我需要将它们全部变为ISerializable吗?

如果我使用ISerializable.我必须实现GetObjectData(),我应该放在该方法中?把它留空是好的吗?

c#

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

C#单元测试代码问题

我们开始使用C#内置单元测试功能.我有VisualStudio 2008为我创建的单元测试代码.我在生成的代码上面几乎没有问题.以下是我从生成的文件中复制的代码:

  #region Additional test attributes
  // 
  //You can use the following additional attributes as you write your tests:
  //
  //Use ClassInitialize to run code before running the first test in the class
  //[ClassInitialize()]
  //public static void MyClassInitialize(TestContext testContext)
  //{
  //}
  //
  //Use ClassCleanup to run code after all tests in a class have run
  //[ClassCleanup()]
  //public static void MyClassCleanup()
  //{
  //}
  //
  //Use TestInitialize to run code before running each test
  //[TestInitialize()]
  //public void MyTestInitialize()
  //{
  //}
  //
  //Use …
Run Code Online (Sandbox Code Playgroud)

c# unit-testing

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