Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

C0246 error

Discussion in 'Scripting' started by comb11, Mar 11, 2021.

  1. comb11

    comb11

    Joined:
    Mar 10, 2021
    Posts:
    5
    i am new to unity but i know quit a bit so i was coding something and i got CS0246 error and i dont get what the problem is and it says the error is on line (7,12) but there is nothing wrong what can i do to fix it?????? here is my code



    using System;
    using System.Collections;
    using System.Collections.Generic;
    public class Data

    public class data
    {
    public BigDouble Coins;

    public BigDouble ClickUpgradeLevel;

    public Data()
    {
    Coins = 0;

    ClickUpgradeLevel = 0;
    }
    }
     
  2. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    as you can see, you repeat your class creation

    Code (CSharp):
    1. public class Data
    2.  
    3. public class data
     
    mopthrow likes this.
  3. comb11

    comb11

    Joined:
    Mar 10, 2021
    Posts:
    5
    thats not the probem i just typed it wrong and put 2 class data by accident but the u know the actual problem?
     
  4. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    remove "public class Data" on line 4

    and i think the class name should start with a big letter.

    Please post the next time, the full error message and not only the id and use code tags, to make it more readable
     
  5. jbnlwilliams1

    jbnlwilliams1

    Joined:
    May 21, 2019
    Posts:
    267
    The double class is part of your problem. You have no {} for the first data class. Also, what is Public Data()? I would recommend you view the following

    Unity C# Survival Guide - Unity Learn
     
  6. comb11

    comb11

    Joined:
    Mar 10, 2021
    Posts:
    5
    the type or name space 'BigDouble' could not be found
     
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    Rather than these forums being your "fix one error and read back the next error" service, you can actually reason about errors and solve them all by yourself... It's amazing!

    In this case it sounds like you're using something that is not part of Unity. Perhaps you need to get that BigDouble from some library? Google might be useful here.

    How to understand compiler and other errors and even fix them yourself:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220
     
    Joe-Censored likes this.
  8. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    So, where in your code where you define what a "BigDouble" is?