C# simple program structure
using System;
namespace HelloWorldApplication
{
class Program
{
static void Main(string[] args)
{
[Link]("Hello BCA IV sem student");
[Link]("Hello ");
}}}
using Directives: These statements import namespaces, allowing you to use the classes
and methods
Namespace Declaration: A namespace is used to organize code and is a container for
related classes, structs
Class Declaration: C# is an object-oriented language, and program logic is defined within
classes.
Main() Method: This is the primary entry point where program execution begins
Statements and Expressions: Inside methods, instructions are executed sequentially
Boxing and unboxing
Boxing
The process of converting a Value Type variable (char, int etc.) to a Reference Type variable
(object) is called Boxing. Boxing is an implicit conversion process where a value type is
wrapped inside an object instance and stored on the heap. Value-type variables are
generally stored on the stack when they are local variables. When they are fields within a
reference type, they are part of the heap-allocated memory for the reference type. Reference
type variables store memory addresses (references) on the stack, while their actual data is
stored
using System;
class BCA
{
static public void Main()
{
// assigned int value
// 23 to number
int number = 23;
// boxing
object obj = number;
// Display the value of obj
[Link]("Value of object is: " + obj);
}
}