Lauri Kyttala

Lauri Kyttala

  • NA
  • 1
  • 2.4k

Compiler Error CS0246

Nov 18 2012 12:54 PM
Hi, I' am a beginner with C# and I run into above menntioned compiler fault, could someone help what is the actual problem with my code?
I can't handle the Productgroup so that the code assemlies, well I suppose there are other faults also, but I don't understand this one.

The type or namespace name 'type/namespace' could not be found (are you missing a using directive or an assembly reference?)

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

namespace Productgroups
{
    public class Product
    {
        public string[] purchases;
        public string Products;
        public string Productgroup;

        public decimal Cost;
        public decimal summary;

        // metodi
        public void t(string[] purchase, string merchandise, string Productgroup, decimal prices, decimal all_together)
        {
            this.purchases = purchase;
            this.Products = merchandise;
            this.Productgroup = Productgroup;

            this.Cost = prices;
            this.summary = all_together;
        }
    }

    class Program
    {
        static void Main()
        {

            Product[] purchases = new Product[2];
            Productgroup applianceGroup = new Productgroup("Home appliance");
            purchases[0] = new Product("Coffee machine", applianceGroup, 49.90M);
            purchases[1] = new Product("Microwave oven", applianceGroup);
            purchases[1].Cost = 99.90M;
            decimal sum = 0;
            foreach (Product t in purchases)
            {
                sum += t.Cost;
                Console.WriteLine(t.summary);
            }
            Console.WriteLine("All together {0:f2}", sum);
        }
    }
}

********

Appreciate you help!

Answers (1)