I have the following form which gives me the error that I cannot implicitly convert type void to HomeInventory2.Domain.CreateInventory…
my form
namespace HomeInventory2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void submitButton_Click(object sender, EventArgs e)
{
CreateInventory create = new CreateInventory();
create.ItemAmount = textBoxAmount.Text;
create.ItemCategory = textBoxCategories.Text;
create.ItemProperties = textBoxValue.Text;
create.ItemValue = textBoxValue.Text;
InventoryMngr invtryMngr = new InventoryMngr();
CreateInventory creating = invtryMngr.Create(create);
}
}
}
and the createinventory file it is referencing
namespace HomeInventory2.Domain
{
[Serializable]
public class CreateInventory
{
private string itemCategory;
public String ItemCategory
{
set { itemCategory = value; }
get { return itemCategory; }
}
private string itemProperties;
public String ItemProperties
{
set { itemProperties = value; }
get { return itemProperties; }
}
private string itemAmount;
public String ItemAmount
{
set { itemAmount = value; }
get { return itemAmount; }
}
private string itemValue;
public String ItemValue
{
set { itemValue = value; }
get { return itemValue; }
}
}
}
Why are you doing:
CreateInventory creating = invtryMngr.Create(create);Why not just:
invtryMngr.Create(create);Cause what you’re doing is creating another
CreateInventorythat, judging by your code posted, doesn’t need to be there. And this is what is giving you the error, becauseinvtryMngr.Create()returns void, most likely.