Ad
  • Custom User Avatar

    Dear Developer,
    I think that there is no point of making such easy exercises, because there are a lot of them.

    Best Regards,
    Vahagn

  • Custom User Avatar

    I think that there is no point of making such easy exercises because there are already a lot of them

    Best Regards
    Vahagn

  • Custom User Avatar

    Random r = new Random();
    means that you create an object of type Random, new Random() initializes it, later you can use later to generate random numbers by calling
    r.Next(); which returns a non-negative random integer
    Next(Int32); returns a non-negative random integer that is less than the specified maximum
    Next(Int32, Int32); returns a random integer that is within a specified range

    Note that it is somewhat similar to creating an array, list, or an object of the type of a class
    int[] i = new int[5]; You create i of type int[] and initialize it specifying its size which is 5
    List l = new List(); You create l of type list and initialize it

    if we have a class named TheClass, we can use its methods and public variables by making an object of its type and initializing it
    class TheClass
    {
    public int n = 0;
    }

    class CallerClass
    {
    TheClass obj = new TheClass();
    int nFromTheClass = obj.n; // nFromTheClass will be 0
    }

    If you have any other questions, please do not hesitate to ask,
    Thank you for the question