Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
sir!
i have written a code but it is giving a error:
the code is below

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Interface_demo
{
    class invoice : ICloneable
    {
        private string invoice_No;
        private float amount;
        private Customer _customer;
        public invoice(string InvoiceNo, float _amount)
        {
            this.invoice_No = InvoiceNo;
            this.amount = _amount;
        }
        public Customer customer
        {
            get
            {
                return this._customer;
            }
            set
            {
                this._customer = value;
            }
        }
        public override string ToString()
        {
            return string.Format("No:{0},Amount:{1:C},customer:{2}", this.invoice_No, this.amount, this._customer.Names);
        }

        public object Clone()
        {
            invoice inv = new invoice(this.invoice_No, this.amount);
            Customer custom = new Customer(this._customer.Names);
            inv._customer = custom;
            return inv;
        }
        static void Main(String[] at)
        {
            invoice invo = new invoice("0001", (float)20000.000);
            invo.customer.Names.ToString() = new Customer.names("stephen");
            invoice invoi = (invoice)invo.Clone();
            invoi.customer.Names = "thomas";
            Console.WriteLine(invo.ToString());
            Console.WriteLine(invoi.ToString());
            Console.ReadLine();
        }
    }
}


        
        class Customer
        {
            private string Name;
            public Customer(string _name)
            {
                this.Name = _name;
            }
            public string Names
            {
                get { return this.Name; }
                set { this.Name = value; }
            }
        }

the error is:
Quote:
Error 1 The type name 'names' does not exist in the type 'Customer' C:\Users\Tushar\Documents\Visual Studio 2010\Projects\Interface_demo\Interface_demo\invoice.cs 44 59 Interface_demo
Posted
Updated 24-Feb-14 7:06am
v2
Comments
Sergey Alexandrovich Kryukov 24-Feb-14 13:08pm    
Why not commenting the line with the problem? Who can we see where 44 59 is located?
—SA

1 solution

C# is a case sensitive language. Look at your code ...
invo.customer.Names.ToString() = new Customer.names("stephen");

This should be
invo.customer.Names.ToString() = new Customer.Names("stephen");
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 24-Feb-14 13:09pm    
I detected it a bit later... :-) My 5.
—SA
CHill60 24-Feb-14 13:16pm    
Thank you - saw your comment to the OP too and agree
Maciej Los 24-Feb-14 13:22pm    
Hawk eye ;)
+5
CHill60 24-Feb-14 13:36pm    
Maciej Los 24-Feb-14 13:42pm    
:laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900