错误(方法必须具有返回类型)&&('是'字段'但用作'类型')

时间:2016-11-21 11:42:39

标签: c#

我想从我的(ImageBox)中名为imgCamUser的计算机默认摄像机节目中进行实时馈送; 但我看到很多错误

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.Util;
using Emgu.CV.UI;
using Emgu.CV;
namespace mmmmmm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            private Capture capture;
 capture = new Capture();
imgCamUser.Image = capture.QueryFrame();
        }
    }
}

但我有这些错误 this error

this list of errors

1 个答案:

答案 0 :(得分:1)

只需写下

Capture capture = new Capture();

而不是

private Capture capture;
capture = new Capture();

因为在方法中声明的变量只能在此方法中可见,所以将它们声明为private,public或protected是没有意义的。