나는 두 개의 클래스가 있습니다. 제품 및 색상. 당신은 새로운 인스턴스로 ProductColor
자체를 설정해야C# 클래스 변수 유형 다른 클래스
public class tblColor
{
public int Id { get; set; }
public string ColorName { get; set; }
}
public class Urun
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public tblRenk ProductColor { get; set; }
}
while (dr.Read())
{
products.Add(new Product()
{
ProductId = Convert.ToInt32(dr["id"].ToString()),
ProductName = dr["ProdName"].ToString(),
?????? ProductColor = dr["ColName"].ToString()
});
}
기다려 .. 내가 여기 메신저 인 멍청한 놈을 생각 .. 그것을 왜 Urun.Add (새 Urun() {ProductId = intVal, ProductName = stringVal, ProductColor = tblRenkVal}); – choz
그래서 ProductColor에는 Colorid 및 ColorName이 포함됩니다. 하나의 변수 두 값 ... – Ata
헝가리 표기법을 사용하지 마십시오. – SLaks