G
Guest
I believe each ways below will produce the same results. But may i know which one will be better and encourage to be used.
Sample1:
class Animal
{
public void GetWeight()
{
}
}
class ClientApp
{
Animal anim = new Animal();
anim.GetWeight();
}
Sample2:
class Animal
{
private static Animal weight;
public static Animal GetWeight()
{
if (weight == null)
{
weight = new Animal();
}
return weight;
}
}
class ClientApp
{
Animal anim = Animal.GetLength();
}
Any help? Thanks.
Sample1:
class Animal
{
public void GetWeight()
{
}
}
class ClientApp
{
Animal anim = new Animal();
anim.GetWeight();
}
Sample2:
class Animal
{
private static Animal weight;
public static Animal GetWeight()
{
if (weight == null)
{
weight = new Animal();
}
return weight;
}
}
class ClientApp
{
Animal anim = Animal.GetLength();
}
Any help? Thanks.