Singleton Error with code

Here is my MySingleton.js javascript with code.I am getting errors mentioned at bottom of code.Need a Score var to be updated in other class where i am accessing it.Please don't mind my stupidity in code as am a newbie....:)Thanks in advance.

public class MySingleton { private static MySingleton instance;

public MySingleton () 
{
    if (instance != null)
    {
        Debug.LogError ("Cannot have two instances of singleton. Self destruction in 3...");
        return;
    }

    instance = this;
}

public static MySingleton Instance
{
    get
    {
        if (instance == null)
        {
            new MySingleton ();
        }

        return instance;
    }
}

  private int score;

public int Score
{
    get
    {
        return score;
    }
    set
    {
        score = value;
    }
}

}

And the Error I am getting is:Assets/Test/MySingleton.js(3,20): BCE0043: Unexpected token: MySingleton.

Assets/Test/MySingleton.js(5,12): BCE0043: Unexpected token: MySingleton.

Assets/Test/MySingleton.js(5,24): BCE0044: expecting EOF, found '('.

Hi,

Here is the full script you need to have:

make sure you create a c sharp script, cause this is csharp, not javascript. And make sure you name the script the same as the classe you define so your script file in your project must be named MySingleton.

using UnityEngine;

public class MySingleton { 

    private static MySingleton instance;

    public MySingleton () 
    {
        if (instance != null)
        {
            Debug.LogError ("Cannot have two instances of singleton. Self destruction in 3...");
            return;
        }

        instance = this;
    }

    public static MySingleton Instance
    {
        get
        {
            if (instance == null)
            {
                new MySingleton ();
            }

            return instance;
        }
    }

      private int score;

    public int Score
    {
        get
        {
            return score;
        }
        set
        {
            score = value;
        }
    }

}

Bye,

Jean