Results 1 to 4 of 4

Thread: [2.0] slight confusion between "Object" vs "object"

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    [2.0] slight confusion between "Object" vs "object"

    while typing using VS 2005, C#, intellisense shows "Object" and "object" .

    what is the difference. The help shows both are Object class . then why Uppercase Object and lower case object is displayed by intellisense?

    nath

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] slight confusion between "Object" vs "object"

    "Object" is a .NET type and "object" is a C# data type. With an upper case "O" it is actually System.Object but without the qualifying namespace. If you remove the "using System;" line from the top of the code file you'll see that you cannot use "Object" anymore. With a lower case "o" it is the the in-built C# object data type. Most languages have in-built data types for the most commonly used types. C# has a number of in-built data types and below is a table of the .NET type that is used to implement implement some of them.
    Code:
    C# data type    .NET type
    
    object          System.Object
    bool            System.Boolean
    int             System.Int32
    float           System.Single
    double          System.Double
    decimal         System.Decimal
    string          System.String
    Note that the .NET types turn a light aqua-ish colour in the IDE and the C# data types, like all language key words, turn a bright blue colour.
    Last edited by jmcilhinney; May 13th, 2006 at 06:59 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    Exclamation Re: [2.0] slight confusion between "Object" vs "object"

    jm,

    can we say object (lower case o which is in-built C# object data type) as an alias for System.Object class?

    I meant object (lower case) is alias of Object?

    thanks
    nath

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] slight confusion between "Object" vs "object"

    All C# data types are implemented using .NET types, so an object and an Object are essentially the same thing. VB.NET has its own data types too. A VB.NET Integer and a C# int are both implemented using the System.In32 structure. I suggest that you start making use of your F1 key. Had you typed a line like:
    Code:
    object o;
    then placed your cursor in the "object" word and pressed F1 it would have taken you straight to the help topic for the object data type, which says:
    The object type is an alias for Object in the .NET Framework.
    where "Object" is a link to the topic for the System.Object class.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width