• About

SharePoint Lab

~ Connect, Communicate, Collaborate!!!

SharePoint Lab

Tag Archives: C# Basic

Boxing changes datatype?

09 Sunday Nov 2008

Posted by Shahid in C# Basic

≈ 1 Comment

Tags

C# Basic

Let’s work with a very simple example in c#. I will not discuss more abut data types in this section [but later] but I will show you inserting thing [really to me]

Int32 i = 100;
object o = null;
o = new object();
System.Console.WriteLine(“The type is:{0}”, i.GetType());    // will print System.Int32
System.Console.WriteLine(“The type is:{0}”, o.GetType());   // will print System.Object
o = i; // Implicit conversion [boxing]
System.Console.WriteLine(“The type is:{0}”, o.GetType());   //will print System.Int32—? but its object  and points to Int32.

As soon as I have assigned the integer to the object the object is of type Int32. So  overcareful when you face this type conversion and work on determining data type. See the output below:

output2

Subscribe

  • Entries (RSS)
  • Comments (RSS)

Archives

  • May 2017
  • April 2017
  • June 2013
  • November 2008

Categories

  • C# Basic
  • PowerApps
  • SharePoint 2010
  • SharePoint Online

Meta

  • Register
  • Log in

Create a free website or blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • SharePoint Lab
    • Already have a WordPress.com account? Log in now.
    • SharePoint Lab
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...