maath frman maath frman - 19 days ago 7
C# Question

Errors (Method must have a return type)&&(' is a 'field' but is used like a 'type')

I want to make live feed from the computer’s default camera show in my (ImageBox) that name imgCamUser;
but i see many errors

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();
}
}
}


but I have this errors
this error

this list of errors

Answer

Just write

Capture capture = new Capture();

instead of

private Capture capture;
capture = new Capture();

because variables declared inside a method are only visible inside this method, so it doesn't make sense in declaring them private, public or protected.