unknow

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
using DataSet1TableAdapters;

/// <summary>
/// Summary description for Class1
/// </summary>
public class Car
{
public Car()
{

}

public Car(int CarID, string Makes, string Models, Boolean Turbo, string Egine, string Transmission, string Color, string Years, decimal Koilmeter, decimal Prics, byte Pictures)
{
_carID = CarID;
_Makes = Makes;
_Models = Models;
_Turbo = Turbo;
_Egine = Egine;
_Transmission = Transmission;
_Color = Color;
_Years = Years;
_Koilmeter = Koilmeter;
_Prices = Prics;
_Pictures = Pictures;
}

private int _carID;

public int carID
{
get { return _carID; }
set { _carID = value; }
}

private string _Makes;

public string Makes
{
get { return _Makes; }
set { _Makes = value; }
}

private string _Models;

public string Models
{
get { return _Models; }
set { _Models = value; }
}

private Boolean _Turbo;

public Boolean Turbo
{
get { return _Turbo; }
set { _Turbo = value; }
}

private string _Egine;

public string Egine
{
get { return _Egine; }
set { _Egine = value; }
}

private string _Transmission;

public string Transmission
{
get { return _Transmission; }
set { _Transmission = value; }
}

private string _Color;

public string Color
{
get { return _Color; }
set { _Color = value; }
}

private string _Years;

public string Years
{
get { return _Years; }
set { _Years = value; }
}

private decimal _Koilmeter;

public decimal Koilmeter
{
get { return _Koilmeter; }
set { _Koilmeter = value; }
}

private decimal _Prices;

public decimal Prices
{
get { return _Prices; }
set { _Prices = value; }
}

private byte _Pictures;

public byte Pictures
{
get { return _Pictures; }
set { _Pictures = value; }
}


private CarinformationTableAdapter _carTA = new CarinformationTableAdapter();

public BindingList<Car> GetDataByMakes(string Makes)
{
DataSet1.CarinformationDataTable table;

table = _carTA.GetDataByMakes(Makes);
BindingList<Car> cars = new BindingList<Car>();

foreach (DataSet1.CarinformationRow row in table)
{
cars.Add(new Car(row.Transmission, row.Color, row.Years, row.Kilometer, row.Prices, row.Pictures, row.Makes, row.Turbo));
}
return cars;

}
}

it said overload for method 'car' takes "8" agurment.

i m not sure what went wrong,pls help



Re: Visual C# General help with overload for method

Hayder Marzouk

Hi,

In the line :

cars.Add(new Car(row.Transmission, row.Color, row.Years, row.Kilometer, row.Prices, row.Pictures, row.Makes, row.Turbo));

u are invoking a constructor with 8 parameters. However the Car class constructor has 11 arguments.

Add the missing arguments or add a new constructor with 8 argumetns :

So, Change the line to

cars.Add(new Car(row.Transmission, row.Color, row.Years, row.Kilometer, row.Prices, row.Pictures, row.Makes, row.Turbo,0, 0,null));

or add the constructor :

public Car(int CarID, string Makes, string Models, Boolean Turbo, string Egine, string Transmission, string Color, string Years)
{
_carID = CarID;
_Makes = Makes;
_Models = Models;
_Turbo = Turbo;
_Egine = Egine;
_Transmission = Transmission;
_Color = Color;
_Years = Years;
_Koilmeter = 0;
_Prices =0;
_Pictures = null;
}

HTH.

Hayder Marzouk