Run time error

I was following this tutorial series (http://www.youtube.com/watch?v=kK1eIk4inAU&list=SPE5C2870574BF4B06) and typed everything the same way he did. code compiled just fine, but when i run it i get a null reference exception error. is this because i’m using unity4 or is there something wrong with my code?

this is my code:
//ModifyingAttribute _mods initialized above

private void CalculateModValue(){
_modValue = 0;

if(_mods.Count > 0)
foreach(ModifyingAttribute att in _mods)
_modValue += (int)(att.attribute.AdjustedBaseValue * att.ratio);
}

public struct ModifyingAttribute {
public Attribute attribute;
public float ratio;

}

A null reference means something isn’t getting assigned to a variable that you are using. Copy and paste the error here.

NullReferenceException: Object reference not set to an instance of an object
ModifiedStats.CalculateModValue () (at Assets/Scripts/Character Classes/ModifiedStats.cs:21)
ModifiedStats.Update () (at Assets/Scripts/Character Classes/ModifiedStats.cs:29)
BaseCharacter.StatUpdate () (at Assets/Scripts/Character Classes/BaseCharacter.cs:122)
CharacterGenerator.Start () (at Assets/Scripts/Character Classes/CharacterGenerator.cs:31)

ModifiedStats.cs 21 is
_modValue += (int)(att.attribute.AdjustedBaseValue * att.ratio);
that line

Well, the first issue to take care of is the missing “{” after “if(_mods.Count>0)”. You also should put a complete set of brackets on the foreach loop. You can get away without them there but only if it remains one line of code. More than one requires the brackets. It’s always a good idea to include them even for a single line like that.

if(_mods.Count > 0)
{
foreach(ModifyingAttribute att in _mods)
   {
     _modValue += (int)(att.attribute.AdjustedBaseValue * att.ratio);
    }
}