问题列表 - 第8338页

何时为gcc使用-O2标志?

如果我使用"-O2"标志,性能会提高,但编译时间会变长.

我该如何决定是否使用它?

也许O2在某些特定类型的代码中有很大差异(例如数学计算?),我应该只将它用于项目的那些部分?

编辑:我想强调的是,为项目的所有组件设置-O2会将总编译时间从10分钟更改为30分钟.

c++ unix optimization gcc

10
推荐指数
4
解决办法
7260
查看次数

WPF UserControl如何继承WPF UserControl?

以下WPF UserControl称为DataTypeWholeNumber,它可以正常工作.

现在我想创建一个名为DataTypeDateTimeDataTypeEmail等的UserControl .

许多依赖属性将由所有这些控件共享,因此我想将它们的公共方法放入BaseDataType中,并使每个UserControl都继承自此基类型.

但是,当我这样做时,我得到错误:部分声明可能没有不同的基类.

那么如何使用UserControls实现继承,以便共享功能全部在基类中?

using System.Windows;
using System.Windows.Controls;

namespace TestDependencyProperty827.DataTypes
{
    public partial class DataTypeWholeNumber : BaseDataType
    {
        public DataTypeWholeNumber()
        {
            InitializeComponent();
            DataContext = this;

            //defaults
            TheWidth = 200;
        }

        public string TheLabel
        {
            get
            {
                return (string)GetValue(TheLabelProperty);
            }
            set
            {
                SetValue(TheLabelProperty, value);
            }
        }

        public static readonly DependencyProperty TheLabelProperty =
            DependencyProperty.Register("TheLabel", typeof(string), typeof(BaseDataType),
            new FrameworkPropertyMetadata());


        public string TheContent
        {
            get
            {
                return (string)GetValue(TheContentProperty);
            } …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml user-controls

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

AI算法有20个问题如何工作?

20个问题的简单在线游戏,由精确的AI精确驱动.

他们怎么猜得那么好?

algorithm artificial-intelligence

100
推荐指数
5
解决办法
7万
查看次数

如何在Firefox上的html表上触发onkeydown事件?

我想捕获表格单元格上的击键.我有以下代码在IE上工作但在Firefox/Chrome上没有.

<table id="testing" onkeydown="alert('testing')"><br />
    <tr><td>testing</td></tr>` <br />
    </table>
<br />
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

javascript firefox

6
推荐指数
1
解决办法
6887
查看次数

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

更改文件创建日期

我可以在Linux中使用Python更改某些文件的创建日期吗?

python linux date file

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

从int到短字符串的双向加密

我正在构建一个小型的Web应用程序,我们的客户可以在其中更新有关其公司的一些详细信息.客户目前没有登录名/密码,我们不想验证他们的注册,所以我们想给他们一个自动生成的密码/密钥来登录网站.

我们计划加密他们的customerId并将其交给客户,以便他可以在webapp上输入该密钥,以便我们将密钥解密为他的ID.

大约有1万名客户,他们并没有收到任何电子邮件,因此有些人会收到一封带有URL和代码的信件.这意味着客户必须输入代码,因此代码不能超过8个字符(最好是6个字符).

这是一个空模板:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int passwordLength = 6;
            int customerId = 12345;
            string encrypted = Crypter.Encrypt(customerId, "secretKey", passwordLength);
            if (customerId == Crypter.Decrypt(encrypted, "secretKey"))
            {
                Console.WriteLine("It worked! Well done!");
            }
        }

    }

    public static class Crypter
    {
        public static string Encrypt(int input, string key, int passwordLength)
        {
            string encryptedString = "";
            //do encrypt stuffz here

            return encryptedString;
        }
        public static int Decrypt(string …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net passwords cryptography

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

获得某些UIColors的颜色组件的异常结果

我正在尝试提取a的rgb组件,UIColor以便手工构建a 中的像素CGBitmapContext.以下示例代码适用于大多数UIColor常量,但令人困惑,并非全部.以机智:

CGColorRef color = [[UIColor yellowColor] CGColor];
const float* rgba = CGColorGetComponents(color);

float r = rgba[0];
float g = rgba[1];
float b = rgba[2];
float a = rgba[3];

NSLog( @"r=%f g=%f b=%f a=%f", r, g, b, a);
Run Code Online (Sandbox Code Playgroud)

[UIColor yellowColor]如上所述,上述结果为
r = 1.000000 g = 1.000000 b = 0.000000 a = 1.000000.

[UIColor redColor]给出r = 1.000000 g = 0.000000 b = 0.000000 a = 1.000000,再次如预期的那样.同样的blueColorgreenColor.

然而,结果[UIColor …

iphone core-graphics cgcolor uicolor

11
推荐指数
1
解决办法
3161
查看次数

使用Resharper时未找到元数据窗口(F12)

当我F12在Visual Studio中点击(或右键单击并选择Go To Definition)代码我没有源代码时,它应该调出生成的元数据文件.(非常类似于代码定义窗口)

安装ReSharper(R#)时,这不起作用.安装R#后,将打开对象浏览器.

我在几台新安装的计算机上遇到过这个问题,至少从R#3开始.(当你禁用R#并重新启动VS时,你会看到这个问题再次起作用)

我现在如何进入元数据视图?

resharper visual-studio

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

将字符串转换为整数

我的代码需要帮助.我想在我的文本框中只编写数字/整数,并希望在我的列表框中显示它.

我的代码是否按顺序排列?这似乎给出了一个错误.

    int yourInteger;
    string newItem;

    newItem = textBox1.Text.Trim();

    if (newItem == Convert.ToInt32(textBox1.Text))
    {
        listBox1.Items.Add(newItem);
    }
Run Code Online (Sandbox Code Playgroud)

====更新:

这就是我的代码现在的样子.我的问题是,listBox可以处理数据类型"long"吗?因为当我输入数字20,000,000时,我只得到一小时玻璃20分钟.但是当我用控制台尝试这个时,我得到了答案.所以我不确定哪种元素可以处理数据类型"long".

    string newItem;
    newItem = textBox1.Text.Trim();

    Int64 num = 0;
    if(Int64.TryParse(textBox1.Text, out num))
    {
        for (long i = 2; i <= num; i++)
        {
            //Controls if i is prime or not
            if ((i % 2 != 0) || (i == 2))
            {
                listBox1.Items.Add(i.ToString());
            }

        }
    }


    private void btnClear_Click(object sender, EventArgs e)
    {
        listBox1.Items.Clear();
    }
Run Code Online (Sandbox Code Playgroud)

.net c# string integer

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