Search Unity

Help me quick please !!!

Discussion in 'Scripting' started by iMihai9, Jun 16, 2018.

  1. iMihai9

    iMihai9

    Joined:
    Jun 4, 2018
    Posts:
    11
    in that code
    Code (CSharp):
    1.    public class Item
    2.     {
    3.         public bool Bought, Selected;
    4.         public int Price;
    5.         public string Name;
    6.  
    7.         public ShopItem(bool bought, bool selected, int price, string name)
    8.         {
    9.             Bought = bought;
    10.             Selected = selected;
    11.             Price = price;
    12.             Name = name;
    13.            
    14.         }
    15.        
    16.     }
    17.  
    i hace that error
    "
    CS1520: class,struct, or interface method must have a return type"

    on that line :
    Code (CSharp):
    1.        public ShopItem(bool bought, bool selected, int price, string name)
    2.  
     
  2. krisu

    krisu

    Joined:
    Jul 10, 2013
    Posts:
    40
    just change public class Item to public class ShopItem

    or

    ShopItem(bool bought, bool selected, int price, string name) to Item(bool bought, bool selected, int price, string name)