小编deo*_*oll的帖子

在这种情况下,为什么整数转换为字符串?

下面发生了什么?

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

public class DotNetPad
{
    public static void Main(string[] args)
    {
        int i = 10;
        string k = "Test";
        Console.WriteLine(i+k);
        Console.WriteLine(k+i);
    }
}
Run Code Online (Sandbox Code Playgroud)

i在两种情况下都被转换为字符串.我对运算符优先级的概念感到困惑(虽然这个例子没有显示出很多)和评估方向.有时评估从左到右进行,反之亦然.我不完全了解表达式如何评估的科学...

为什么i在上面的例子中转换为字符串,而不是实际给出编译错误?

c# evaluation operators associativity

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

JQuery Flot:清晰的图形

是否有推荐的方法来清除jQuery Flot图?我在API参考中找不到任何内容.

jquery graph flot clear

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

在ManualResetEvent或Thread.Sleep()之间做出选择

我不确定采用哪种策略......我专注于我的操作完成,但我也想将性能问题保持在最低限度......有一种名为Execute()的方法必须等待(同步运行)直到操作完成.此操作发生在另一个线程上.有两种方法可以实现同样的事情......

通过使用ManualResetEvent

void Execute()
{
    taskHandle = new ManualResetEvent(false);
    .
    .
    //delegate task to another thread
    .
    .
    taskHandle.WaitOne();
}
Run Code Online (Sandbox Code Playgroud)

要么

通过使用简单的while构造

void Execute()
{
    .
    .
    //delegate task to another thread
    .
    .
    while (!JobCompleted)
        Thread.Sleep(1000);
}
Run Code Online (Sandbox Code Playgroud)

我应采用两种方法中的哪一种......为什么?

编辑:

Q2.如果我在构造时只是空了怎么办?有什么不同...?

while(!JobCompleted);
Run Code Online (Sandbox Code Playgroud)

编辑:(之前我收集过的东西)

http://www.yoda.arachsys.com/csharp/threads/waithandles.shtml - 这篇文章说手动复制比较慢,因为它们离开了托管代码并重新进入......

c# multithreading sleep manualresetevent

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

C#:使用System.Speech命名空间将WAV文件转录为文本(语音到文本)

你如何使用.NET语音命名空间类将WAV文件中的音频转换为文本形式,我可以在屏幕上显示或保存到文件?

我正在寻找一些教程样本.

UPDATE

在这里找到了代码示例.但是当我尝试它时它给出了不正确的结果.下面是我采用的vb代码示例.(其实我不介意lang,只要它的vb/c#...).它没有给我正确的结果.我假设如果我们把正确的语法 - 即我们在录音中所期望的单词 - 我们应该得到它的文本输出.首先,我尝试了调用中的示例单词.它有时只打印那个(一个)字而不是其他字.然后我尝试了一些我们在录音中完全没有想到的词......不幸的是它也打印出来...... :(

Imports System
Imports System.Speech.Recognition

Public Class Form1

    Dim WithEvents sre As SpeechRecognitionEngine

    Private Sub btnLiterate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLiterate.Click
        If TextBox1.Text.Trim.Length = 0 Then Exit Sub
        sre.SetInputToWaveFile(TextBox1.Text)
        Dim r As RecognitionResult
        r = sre.Recognize()
        If r Is Nothing Then
            TextBox2.Text = "Could not fetch result"
            Return
        End If
        TextBox2.Text = r.Text
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) …
Run Code Online (Sandbox Code Playgroud)

c# namespaces speech-to-text

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

beautifulsoup:找到第n个元素的兄弟姐妹

我有一个具有以下性质的复杂html DOM树:

<table>
    ...
    <tr>
        <td>
            ...
        </td>
        <td>
            <table>
                <tr>
                    <td>
                        <!-- inner most table -->
                        <table>
                            ...
                        </table>

                        <h2>This is hell!</h2>
                    <td>
                </tr>
            </table>
        </td>
    </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

我有一些逻辑来找出最内层的表.但在找到它之后,我需要获得下一个兄弟元素(h2).无论如何你可以这样做吗?

python beautifulsoup find siblings

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

如何创建VirtualHost以仅提供静态内容

我想在apache中创建一个虚拟主机,它只提供静态内容,如样式表,视频,图像,javascripts,文本文件等.我不是在寻找这个虚拟主机的任何"处理"功能.

apache virtualhost static-content

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

字符串变量未在多行字符串中替换

这是代码/输出所有在一起:

PS C:\code\misc> cat .\test.ps1; echo ----; .\test.ps1
$user="arun"
$password="1234*"
$jsonStr = @"
{
        "proxy": "http://$user:$password@org.proxy.com:80",
        "https-proxy": "http://$user:$password@org.proxy.com:80"
}
"@
del out.txt
echo $jsonStr >> out.txt
cat out.txt
----
{
        "proxy": "http://1234*@org.proxy.com:80",
        "https-proxy": "http://1234*@org.proxy.com:80"
}
Run Code Online (Sandbox Code Playgroud)

字符串变量的$user内容未被替换$jsonStr.

替换它的正确方法是什么?

string powershell concatenation multiline substitution

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

删除node_modules文件夹

问题:

我在我的窗户盒子上错误地创建了一个自耕农项目.通过资源管理器,当我尝试删除它时,我得到一个错误,说路径太长.

来源太长错误

几种方案:

但是有基于脚本的解决方案吗?

windows directory npm yeoman

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

反映.net中的常量属性/字段

我有一个类如下:

public class MyConstants
{
    public const int ONE = 1;
    public const int TWO = 2;

    Type thisObject;
    public MyConstants()
    {
        thisObject = this.GetType();
    }

    public void EnumerateConstants()
    {
        PropertyInfo[] thisObjectProperties = thisObject.GetProperties(BindingFlags.Public);
        foreach (PropertyInfo info in thisObjectProperties)
        {
            //need code to find out of the property is a constant
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

基本上它正试图反思自己.我知道如何反映字段ONE和TWO.但我怎么知道它是不是常数?

.net c# reflection constants

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

为什么这个python脚本会一直等到执行计时器线程?

from threading import Timer

def startTimer():

  t = Timer(10.0, foo, ['hello world', 'tell me more'] )
  t.start()
  print 'Timer function invoked'
  print 'function exit'

def foo(msg, msg2):
  print 'foo was executed'
  print msg
  print msg2

if __name__ == '__main__':  
  startTimer()
  print 'end of program'
Run Code Online (Sandbox Code Playgroud)

我已将上述代码保存在文件(timer.py)中,然后在shell中键入python timer.py.但它一直等到foo()被执行.为什么会这样?你怎么称呼这种行为/执行方式?

python execution

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