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

问题描述:

我想从我的(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

在'private Capture'中删除'private';应该只是'Capture capture;' –

只要写

​​

,而不是

private Capture capture; 
capture = new Capture(); 

因为在方法中声明的变量只能在这个方法内部看到,所以在声明它们是私有的,公共的或者保护的时候是没有意义的。

+0

谢谢,但是返回新错误“错误不能隐式地将类型'Emgu.CV.Mat'转换为'System.Drawing.Image' –

+0

这是另一个问题 – Toshi