hi, already i have expained to read value from Dictionary using DictionaryEntry, but again you made mistake...
inside if condn you need to change code like this : player =(Player)HomeHsh[HomeHshKey.Key];
publicvoidPointsDecider() {foreach(DictionaryEntryHomeHshKeyinHomeHsh) { //Get the players data Player p =HomeHshKey.ValueasPlayer; //We need position so we can work out points int position = p.PositionID; int numberRuns = p.NumberRuns; decimal strikeRate
= p.StrikeRate; int esaPlayerID
= p.EsaPlayerID; int wickets = p.Wickets; int teamid = p.TeamID; decimal economy
= p.Economy; if(position
==45) { //Edit players key in hash player =(Player)HomeHsh[HomeHshKey.Key];
bp =newBowlerPoints(numberRuns,strikeRate,BonusHsh,esaPlayerID, wickets,WinnerID, teamid, economy);
player.TotalPoints= bp.TotalScore; } } }
Thanks,
Karthick S
Marked as answer by luke_bryant on Apr 30, 2012 01:37 PM
karthicks
All-Star
31382 Points
5424 Posts
Re: Object not set to instance of object
Apr 30, 2012 01:21 PM|LINK
hi, already i have expained to read value from Dictionary using DictionaryEntry, but again you made mistake...
inside if condn you need to change code like this : player = (Player)HomeHsh[HomeHshKey.Key];
public void PointsDecider()
{ foreach(DictionaryEntry HomeHshKey in HomeHsh)
{
//Get the players data
Player p = HomeHshKey.Value as Player;
//We need position so we can work out points
int position = p.PositionID;
int numberRuns = p.NumberRuns;
decimal strikeRate = p.StrikeRate;
int esaPlayerID = p.EsaPlayerID;
int wickets = p.Wickets;
int teamid = p.TeamID;
decimal economy = p.Economy;
if (position == 45)
{
//Edit players key in hash
player = (Player)HomeHsh[HomeHshKey.Key];
bp = new BowlerPoints(numberRuns,strikeRate, BonusHsh,esaPlayerID, wickets, WinnerID, teamid, economy);
player.TotalPoints = bp.TotalScore;
}
}
}
Karthick S