63 146
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #48752 in C# for Julio Diaz

Question #48752
You are writing code for a KINKOS class. The KINKOS class contains the name and
price of a product. You need to override the base class (System.Object) method ToString
to provide information about the objects of the KINKOS class to the calling code. What
code do you need to write in order to meet this requirement?
Expert's answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace quest48752
{
    class Program
    {
        class KINKOS
        {
            public string Name { get; set; }
            public int Price { get; set; }
            public override string ToString()
            {
                return "Name: " + Name + " Price of product : " + Price;
            }
        }
        static void Main(string[] args)
        {
            Console.Write("Enter the name : ");
            string name = Console.ReadLine();
            Console.Write("Enter the price of prodect : ");
            int price = Convert.ToInt32( Console.ReadLine() );
            KINKOS kinkos = new KINKOS { Name = name, Price = price };
            Console.WriteLine(kinkos);
            Console.ReadLine();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions