tmueller18
asked on
Question object object creation
I have a couple of classes listed below
public class House
{
public House()
{
}
// attributes
int houseID = 0;
// Get HouseIDID
public int HouseID{
get { return houseID; }
set { houseID = value; }
}
}
-----------------
public class HouseServices
{
public static House GetHouseByID(int houseID)
{
House result;
// data access stuff
result = ConvertHouseInfoDataTableT oHouse(Hou seInfo);
HouseInfo = null;
return result;
}
public bool UpdateHouse(House House)
{
bool result = true;
// data access stuff
return result;
}
}
-------------------------- -------
code calling these classes:
-------------------------- -------
#1
House myHouse;
myHouse = HouseServices.GetHouseByID (3);
myHouse.ID.ToString()
etc...
#2
HouseServices houseServices = new HouseServices();
houseServices.UpdateHouse( house)
-------------------------- -
Questions:
-------------------------- -
A. Why do I need to create an object for the updatehosue method for #2?
B. House myHouse. What is myHouse called? Is it a Class variable? Its not an object as it is.
C. Why dont I need to create a HouseServices object for #1?
public class House
{
public House()
{
}
// attributes
int houseID = 0;
// Get HouseIDID
public int HouseID{
get { return houseID; }
set { houseID = value; }
}
}
-----------------
public class HouseServices
{
public static House GetHouseByID(int houseID)
{
House result;
// data access stuff
result = ConvertHouseInfoDataTableT
HouseInfo = null;
return result;
}
public bool UpdateHouse(House House)
{
bool result = true;
// data access stuff
return result;
}
}
--------------------------
code calling these classes:
--------------------------
#1
House myHouse;
myHouse = HouseServices.GetHouseByID
myHouse.ID.ToString()
etc...
#2
HouseServices houseServices = new HouseServices();
houseServices.UpdateHouse(
--------------------------
Questions:
--------------------------
A. Why do I need to create an object for the updatehosue method for #2?
B. House myHouse. What is myHouse called? Is it a Class variable? Its not an object as it is.
C. Why dont I need to create a HouseServices object for #1?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.