The repository contains a collection of different programming snippets to different programming languages from own developments as well as other projects
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
programming-examples/c-sharp/Functions/C# Program to Demonstrate B...

39 lines
817 B

/*
* C# Program to Demonstrate Boxing Operations
*/
using System;
class sample
{
int x = 10;
object obj;
void boxmethod()
{
sample s= new sample();
bool b;
object ob="CSHARP";
b=s.obj is int;
Console.WriteLine(b);
s.obj = x;
b = s.obj is int;
Console.WriteLine("{0},{1},{2}",s.obj,s.x,b);
s.x = (int)s.obj;
s.x = 20;
b = s.obj is int;
Console.WriteLine("{0},{1},{2}", s.obj, s.x, b);
s.obj="CSHARP";
b=s.obj is int;
Console.WriteLine("{0},{1},{2}",s.obj,s.x,b);
Console.ReadLine();
}
public static void Main()
{
sample s=new sample();
s.boxmethod();
}
}
/*
False
10,10,True
10,20,True
CSHARP,20,False