Ejemplo n.º 1
0
    public static void Main()
    {
        ProperiesDemo pd = new ProperiesDemo();

        //pd.SetId(-10);

        //-------------------------------------------------------------------------------------------------
        // If we set value less than 0 then exception will be thrown i.e Id should not be less than zero
        //-------------------------------------------------------------------------------------------------

        pd.Id = 10;

        Console.WriteLine(pd.Id);

        //pd.Name = null;

        //-------------------------------------------------------------------------------------------------
        // If we set name as null then exception weill be rised saying Name should not be null or empty
        //-------------------------------------------------------------------------------------------------

        Console.WriteLine(pd.Name);

        //-------------------------------------------------------------------------------------------------
        // If we trying to get unassign name then we will get No Name.
        //-------------------------------------------------------------------------------------------------

        pd.Name = "Hello";

        //-------------------------------------------------------------------------------------------------
        // If we trying to get unassign name then we will get No Name.
        //-------------------------------------------------------------------------------------------------

        Console.WriteLine(pd.Name);

        //-------------------------------------------------------------------------------------------------
        // From the above code we will get exact assigned name.
        //-------------------------------------------------------------------------------------------------


        //pd.PassMark = 45;

        //-------------------------------------------------------------------------------------------------
        // As passCode is read only so not such method found and we cannot assign value to the PassCode.
        //-------------------------------------------------------------------------------------------------

        Console.WriteLine(pd.PassMark);

        //-------------------------------------------------------------------------------------------------
        // Here we get the value of passCode which is already set.
        //-------------------------------------------------------------------------------------------------

        pd.City  = "Pune";
        pd.Email = "*****@*****.**";

        Console.WriteLine(pd.City);
        Console.WriteLine(pd.Email);
    }
Ejemplo n.º 2
0
    public static void Main()
    {
        ProperiesDemo pd = new ProperiesDemo();

        //pd.SetId(-10);

        //-------------------------------------------------------------------------------------------------
        // If we set value less than 0 then exception will be thrown i.e Id should not be less than zero
        //-------------------------------------------------------------------------------------------------

        pd.SetId(10);

        //pd.SetName(null);

        //-------------------------------------------------------------------------------------------------
        // If we set name as null then exception weill be rised saying Name should not be null or empty
        //-------------------------------------------------------------------------------------------------

        Console.WriteLine(pd.GetName());

        //-------------------------------------------------------------------------------------------------
        // If we trying to get unassign name then we will get No Name.
        //-------------------------------------------------------------------------------------------------

        pd.SetName("Hello");

        //-------------------------------------------------------------------------------------------------
        // If we trying to get unassign name then we will get No Name.
        //-------------------------------------------------------------------------------------------------

        Console.WriteLine(pd.GetName());

        //-------------------------------------------------------------------------------------------------
        // From the above code we will get exact assigned name.
        //-------------------------------------------------------------------------------------------------


        //pd.setPassCode(45);

        //-------------------------------------------------------------------------------------------------
        // As passCode is read only so not such method found and we cannot assign value to the PassCode.
        //-------------------------------------------------------------------------------------------------

        Console.WriteLine(pd.GetPassCode());

        //-------------------------------------------------------------------------------------------------
        // Here we get the value of passCode which is already set.
        //-------------------------------------------------------------------------------------------------
    }