Search Unity

I am very new to coding using C# script

Discussion in 'Getting Started' started by techno2fst, Mar 18, 2019.

  1. techno2fst

    techno2fst

    Joined:
    Mar 18, 2019
    Posts:
    2
    I am using Microsoft visual studio and i have error CS0103 (22,50) in this code.
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class NewBehaviourScript : MonoBehaviour {
    private int purchases;
    private int purchasesPerClick;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update() {


    }


    public void ClickPurchases() => purchases += PurchasesPerClick;
    }


    I am sorry but its probably obvious but i am clueless.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Post code using code tags so it makes it easier to read and provides line numbers (so we don't have to manually count the lines just to get to the line with the error).

    Try changing this:
    Code (csharp):
    1. public void ClickPurchases() => purchases += PurchasesPerClick;
    to this:
    Code (csharp):
    1. public void ClickPurchases()
    2. {
    3.     purchases += purchasesPerClick;
    4. }
    Also, I don't see anywhere in your code where you are setting the values of purchases or purchasesPerClick.
     
  3. techno2fst

    techno2fst

    Joined:
    Mar 18, 2019
    Posts:
    2
    thanks ill try that.