G
Guest
C#
I am new to C#, and new to the whole OO concepts, and so I am sure this is a
very stupid question, but I'll ask anyway. When should my methods be static?
I have several "Business Objects" in my app, which basically hold key
functionality. For example I have an Asset class. In there I have some
methods for getting various attributes of an asset. For example I have this:
public class Asset
{
public string GetAssetName(SqlInt64 AssetObj)
{
// Connect to DB, Find the Asset Record and then
// return a string of the asset name
}
}
So to call this I need code like this:
Asset myAsset = new Asset();
String sName = myAsset.GetAssetName(this.AssetObj)
I'm thinking this should be a static method?? But I dont know why.
Thanks
I am new to C#, and new to the whole OO concepts, and so I am sure this is a
very stupid question, but I'll ask anyway. When should my methods be static?
I have several "Business Objects" in my app, which basically hold key
functionality. For example I have an Asset class. In there I have some
methods for getting various attributes of an asset. For example I have this:
public class Asset
{
public string GetAssetName(SqlInt64 AssetObj)
{
// Connect to DB, Find the Asset Record and then
// return a string of the asset name
}
}
So to call this I need code like this:
Asset myAsset = new Asset();
String sName = myAsset.GetAssetName(this.AssetObj)
I'm thinking this should be a static method?? But I dont know why.
Thanks