Q:

System.DivideByZeroException occurred , asp.net mvc

I have a method, like this:
public decimal VerschilPercentage
{
    get
    {               
        {
            return ((Run1.Netto - Run2.Netto)/Run2.Netto)*100;
        }            
    }
}

and this is the class:
public class RunGegevens
{
    public decimal Netto { get; set; }
    public decimal Herr { get; set; }
}

But I get every time this message:

An exception of type 'System.DivideByZeroException' occurred in mscorlib.dll but was not handled in user code.

So my question is:
How to skip the zero's?
Thank you

A:

Easy, you can use a short if :
public decimal VerschilPercentage
{
    get
    {               
        {
            return Run2.Netto == 0 ? 0 : ((Run1.Netto - Run2.Netto)/Run2.Netto)*100;
        }            
    }
}

