小编hud*_*uda的帖子

CS0120:非静态字段,方法或属性'foo'需要对象引用

考虑:

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //int[] val = { 0, 0};
            int val;
            if (textBox1.Text == "")
            {
                MessageBox.Show("Input any no");
            }
            else
            {
                val = Convert.ToInt32(textBox1.Text);
                Thread ot1 = new Thread(new ParameterizedThreadStart(SumData));
                ot1.Start(val);
            }
        }

        private static void ReadData(object state)
        {
            System.Windows.Forms.Application.Run();
        }

        void setTextboxText(int result)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new IntDelegate(SetTextboxTextSafe), new object[] { result });
            }
            else
            {
                SetTextboxTextSafe(result); …
Run Code Online (Sandbox Code Playgroud)

c#

242
推荐指数
6
解决办法
92万
查看次数

如何在chrome扩展中单击contextmenu项目上打开default_popup

如何在chrome扩展中单击contextmenu项目上打开default_popup

反正是吗?当用户点击上下文菜单项时,我们可以调用/打开在default_popup中定义的用于浏览器操作的html文件.

我已经通过以下链接.答案是否定的(任何可能的方式).如果没有我做什么来实现这个任何替代方案?

如何打开 - 默认弹出 - 从 - 上下文 - 菜单 - 在Chrome扩展程序中
如何开启我的扩展程序 - 弹出式与javascript

html javascript jquery google-chrome google-chrome-extension

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

如何使用ThreadPool类

namespace ThPool
{
    class Program
    {
        private static long val = 0;
        private static string obj = string.Empty;

        static void Main(string[] args)
        {
            Thread objThread1 = new Thread(new ThreadStart(IncrementValue));
            objThread1.Start();
            Thread objThread2 = new Thread(new ThreadStart(IncrementValue));
            objThread2.Start();
            objThread1.Join();
            objThread2.Join();

            Console.WriteLine("val=" + val + " however it should be " + (10000000 + 10000000));

            Console.ReadLine();
        }

        private static void IncrementValue()
        {
            for (int i = 0; i < 10000000; i++)
            {
                Monitor.Enter(obj);
                val++;
                Monitor.Exit(obj);
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如何使用ThreadPool类替换线程和监视器?

c#

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

如何在匹配字符串之前找到一个单词

通过堆栈溢出问题,但没有得到正确的答案.我需要在匹配字符串之前和之后使用单独的正则表达式.

1)找到一个特定的短语/单词后的单词(这个工作正常)

  var regex = new Regex(@"(?:" + mytext + @"\s)(?<word>\b\S+\b)");
Run Code Online (Sandbox Code Playgroud)

2)在特定短语/单词之前找到单词(不起作用)

 var regex = new Regex(@"(?:\S+\s)?\S*" + mytext  + @"\b\S");
Run Code Online (Sandbox Code Playgroud)

mytext的= "XYZ"

输入="这是abc xyz defg"

输出应该是这样的

1)首先,这是工作
xyz defg

2)第二,这是行不通的

abc xyz

c# regex

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