using System;
class X
{
    int y;
    public X(int a)
    {
        y = a;
    }
    public int add(X o)
    {
        return y + o.y;
    }
}
// Demonstrate NullReferenceException.
class NREDemo
{
    public static void Main()
    {
        X p = new X(10);
        X q = null; // q is explicitly assigned null
        int val;
        try
        {
            Console.WriteLine("DEF");
            val = p.add(q); // this will lead to an exception
            Console.WriteLine("ABC");
        }
        catch (NullReferenceException)
        {
            Console.WriteLine("NullReferenceException!");
            Console.WriteLine("fixing...\n");
            // now, fix it
            q = new X(19);
            val = p.add(q);
        }
        Console.WriteLine("val is {0}", val);
        Console.ReadKey();
    }
}

In this progg
1. what is the type of o.y
Is it like o is an object of class X
and y is int.
after multiplying them both why isn't it giving error of type mismatch

2. can null overload any parameter type in method like here in method add
the value is passed null and it is accepting that

value. Is it now the value of "o" or o.y
If it is the value of o.y, why it is so
because we have passed the value to add method and there the parameter is o
which will wrap the value

3.Can we add any integer value with null.

4. 4.On compilation
            Console.WriteLine("ABC");
This line is not giving any warning which should be given
which generally appears for the part of a code which doesn't undergo any
execution.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web 
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/DotNetDevelopment

You may subscribe to group Feeds using a RSS Feed Reader to stay upto date 
using following url  

<a href="http://feeds.feedburner.com/DotNetDevelopment";> 
http://feeds.feedburner.com/DotNetDevelopment</a>
-~----------~----~----~----~------~----~------~--~---

Reply via email to