PDA

View Full Version : سوال: نمایش calss بوسیله textbox



rezaesmaeli
یک شنبه 20 آذر 1390, 20:06 عصر
یک کلاسی به نام Car ایجاد کنید داخل آن یک constructor عادی یک constructor company یک constructor Model یک constructor Year بوسیله text box دو عددcar نمایش دهید یکی به صورت()Car دیگری به صورت(Car(company,Model,Yearچگونه کدی باید بنویسم ؟؟؟ کدام public کدام private:متفکر::متفکر::ناراحت::اف سرده::گریه:

saeed262626
دوشنبه 21 آذر 1390, 19:43 عصر
using System;
namespace ConsoleApplication1
{
class Car
{

public string Company { get; set; }
public string Model { get; set; }
public string Year { get; set; }

public Car()
{
}
public Car(string company, string model, string year)
{
Company = company;
Model = model;
Year = year;
}
}
class Program
{
static void Main(string[] args)
{
Car Bmw = new Car("BMW", "BMW 7 series", "2011");
Console.Write("car-name->" + Bmw.Company+",car-model-->"+Bmw.Model+",year-->"+Bmw.Year);
Console.Read();

}
}
}