HavocXphere
Honorary Master
EDIT: Nevermind. Problem solved.
I'm busy writing a Steam Specials monitoring app. Visual C# 2010 Express.
I've painted myself into a bit of a corner with my attempt at OO.
2 classes: GameList contains an ArrayList of class SteamGame. The relevant code fragments:
And me trying to utilize them:
That all works as expected. I can copy something out of the ArrayList (Very last line in code). But I want to access the SHA1 method while its still in the ArrayList & it doesn't let me do that. I want to:
The compiler doesn't like that:
I'm thinking there is some problem with the (SteamGame) casting. Any help would be appreciated.
I'm busy writing a Steam Specials monitoring app. Visual C# 2010 Express.
I've painted myself into a bit of a corner with my attempt at OO.
2 classes: GameList contains an ArrayList of class SteamGame. The relevant code fragments:
Code:
public class SteamGame
{
public string GameName = "", GameURL ="", NewPrice = "", OldPrice = "";
private string SHA1Hash = "";
public string SHA1()
{
//If its not available yet then calculate it
if (SHA1Hash == "")
<snip>
Code:
public class GameList
{
public ArrayList _dataList = new ArrayList();
public string SHA1()
{
//If its not available yet then calculate it
if (SHA1Hash == "")
{
SHA1Hash = BitConverter.ToString(SHA1Managed.Create().ComputeHash(Encoding.Default.GetBytes(GameName+GameURL+OldPrice+NewPrice))).Replace("-", "");
}
//Return the hash
return SHA1Hash;
}
public SteamGame (string GameName, string GameURL, string NewPrice, string OldPrice)
{
this.GameName = GameName;
this.GameURL = GameURL;
this.NewPrice = NewPrice;
this.OldPrice = OldPrice;
}
And me trying to utilize them:
Code:
//Create MyList
GameList MyList = new GameList();
//Add a game
MyList.AddGame("MyGame","MyURL","MyOldPrice","MyNewPrice");
SteamGame MyGame = (SteamGame)MyList._dataList[0];
That all works as expected. I can copy something out of the ArrayList (Very last line in code). But I want to access the SHA1 method while its still in the ArrayList & it doesn't let me do that. I want to:
Code:
string SHA = (SteamGame)MyList._dataList[0].SHA1();
The compiler doesn't like that:
Code:
'object' does not contain a definition for 'SHA1' and no extension method 'SHA1' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Last edited: