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; } } }
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
invo.customer.Names.ToString() = new Customer.names("stephen");
invo.customer.Names.ToString() = new Customer.Names("stephen");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)