Quinton Scott
Quinton Scott

Reputation: 19

Namespace Error on MonoDevelop

I have been getting the following error. 1 :the type or namespace name' CountDownTime' does not exist in the namespace 'System'(are you missing an assembly reference) 2 : the type or namespace naem 'Runtime' does not exist in the namespace Andriod.OS( are you missing an assembly reference)

I would like the code to generate 10 subtraction question, present the answer, and then give the time spent on the test.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CountDownTimer;

using Android.App;
using Android.Content;
using Android.OS.Runtime;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
using Android;

namespace Jagtutor
{
    public class Subtraction : View
    {
        public Subtraction (Context context, IAttributeSet attrs) :
            base (context, attrs)
        {
            Initialize ();
        }

        public Subtraction (Context context, IAttributeSet attrs, int defStyle) :
            base (context, attrs, defStyle)
        {
            Initialize ();
        }

        private void Initialize ()
        {
            int correctCount;
            int count = 0;
            long startTime = CountDownTimer(0);

            while (count < 10)
            {
                // Generate two random single-digit numbers
                srand(CountDownTimer(0));
                int number1 = Random() % 10;
                int number2 = Random() % 10;

                // if number1 < number, swap number1 with number2
                if (number1 < number2)
                {
                    int temp = number1;
                    number1 = number2;
                    number2 = temp; 

                    // PROMPT THE STUDENT TO ANSWER " WHAT IS NUMBERE1 - NUMBER2?"
                    Console.WriteLine("WHAT IS ")(number1);" - "(number2)("?");

                    // Grade the answer and display the result
                    if (number1 - number2 == answer){
                        Console.Write("You are correct!");
                        correctCount++;
                    }
                    else
                        Console.WriteLine("Your answer is wrong");
                    Console.WriteLine(number1);"-"(number2); " should be" (number1 - number2);

                    // increase the count 
                    count++;
                }
                long endTime = CountDownTimer(0);
                long testTime = endTime - startTime; 

                Console.Write(" Correct count is ")(correctCount);" Test time is" (testTime)("seconds");
                return 0;
            }

        }
    }

}

Upvotes: 1

Views: 1050

Answers (2)

jonp
jonp

Reputation: 13600

The C# using directive is used with namespaces, not types. There is no System.CountDownTimer namespace, hence the error.

For that matter, there isn't a System.CountDownTimer type either; it's Android.OS.CountDownTimer, so you'd need:

using Android.OS;

Similarly, there is no Android.OS.Runtime namespace, so using Android.OS.Runtime; will also generate a compile-time error; remove it.

Upvotes: 1

jpobst
jpobst

Reputation: 9982

With the other ones, add:

using Android.OS;

Upvotes: 0

Related Questions