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?
1
Expert's answer
2014-11-11T00:42:54-0500
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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS