-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Rohit_BD
Message 6 in Discussion




  
    
    New Message on MumbaiUserGroup
  
  





      Question Of The Day !!!!

    
  
    
      Reply

          
            
                
               
                  Reply to Sender
                    Recommend
                  
                  Message 4 in Discussion
                                                
            
          
        
                    
        
            
              From: 
              Rohit_BD
            
            
              

              


  
    
    New Message on MumbaiUserGroup
  
  





      Question Of The Day !!!!

    
  
    
      Reply

          
            
                
               
                  Reply to Sender
                    Recommend
                  
                  Message 3 in Discussion
                                                
            
          
        
                    
        
            
              From: 
              Rohit_BD
            
            
              

              


  
    
    New Message on MumbaiUserGroup
  
  





      Question Of The Day !!!!

    
  
    
      Reply

          
            
                
               
                  Reply to Sender
                    Recommend
                  
                  Message 2 in Discussion
                                                
            
          
        
                    
        
            
              From: 
              Rohit_BD
            
            
              

              A null basically means that a variable hasn't been initialised to 
a valid address. Note that in .Net, variables of user-types or non-integral 
types are internally treated as pointers. 

Example:
int i; //Integral type - i represents "normal" data
MyClass o; //Non-integral type - o represents "address" data

Here "i" represents the name given to the block of memory allocated by the 
run-time, and this block of memory is normal integer data. But "o" is the name 
of a block of memory which contains, as it's data the *address* of some other 
block of memory - "o" is a pointer variable, although Java, C# & VB.NET hide 
this from us. The address (or data in "o") is null by default (just as "bool" 
is initialised to false or "int" is initialised to 0), and is valid when the 
"new" operator is invoked with the class name. DBNull represents a "value" of 
null in an object - i.e., while the object (pointer) itself may not be null, 
what it points to contains null as data. To make it clear, suppose we declare a 
class MyClass as -

class MyClass
{
/**/ public String s; //s is the data held by the object.

/**/ MyClass() //Constructor
/**/ {
/**/ /**/ s = null; /* Initialise to null */
/**/ }
}

Now, difference in null & DBNull
MyClass myObj; /* myObj is going to be null and accessing it will result in 
null-reference exception. */

myObj.s = "abcd"; /* Statement fails, null-ref. exception on myObj. */

myObj = new MyClass(); /* Here new operator returns an address which is now 
stored in myObj. */

myObj.s.ToString() /* Fails, since s is null even though mObj is not (in this 
example I have used a non-integral type). */

A more familiar example is that of a dataview where although the dataview is 
not null, and has rows & columns in it, a particular column may contain a null 
in it.

DataView dv = GetDataView(); /* Fire SQL query */

Assume that a column (on 0th index of 0th row in the dataview) contains NULL 
since the underlying database table had that column to have NULL, then, 
dv[0][0] will not be null, but dv[0][0].ToString() will fail, since dv[0][0] 
contains a null value. In this particular example, dv[0][0].ToString() operates 
not on dv[0][0], but on the value it contains - it might appear to contradict 
the MyClass example that I gave above myObj.s.ToString() is equivalent to 
dv[0][0].ToString().

A simple example in C notation:
int *p; //p contains random data since C does not initialise.
int i; //i contains random data since C does not initialise.

i = 0; //valid
*p = 0; /* Invalid, will result in program crash, since p will contain some 
random data, and due to the "*" system iterprets it as an address - trying to 
access random memory location causes invalid memory access fault. */

p =  /* valid, assign address of i using the " operator. */
p = new int; /* valid, assign address of memory block using "new" operator. */

*p = 0; /* Now it's valid, since p already has valid data (address). */

Hope this helps.
          
        
      
          
  

    View other groups in this category.
  

  

      



          
        
      
          
  

    View other groups in this category.
  

  

      



          
        
      
          
  

    View other groups in this category.
  

  

      




-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to