Examveda

What will be the output of the following C# code snippet?
class Program
{
    static void Main(string[] args)
    {
        Expression<Func<int, int, bool>>
        IsFactorExp = (n, d) => (d != 0) ? (n % d) == 0 : false;
        Func<int, int, bool> IsFactor = IsFactorExp.Compile();
        if (IsFactor(10, 5))
        Console.WriteLine("5 is a factor of 10.");
        if (!IsFactor(343, 7))
        Console.WriteLine("7 is not a factor of 10.");
        Console.ReadLine();
    }
}

A. Compile time error

B. Run time error

C. 5 is a factor of 10
7 is not a factor of 10

D. 5 is a factor of 10

Answer: Option D


Join The Discussion

Related Questions on LINQ (Language Integrated Query) in C Sharp