stuart-d2
5/12/2015 - 10:38 AM

Struct : DateTime

Struct : DateTime

//datetime is a struct
//Creating a copy does not effect the original
//The memory is kept separate.  

class Program {

static void Main()
{
	//DateTime is a struct
	DateTime date = new DateTime(2000, 1, 1);  
	
	//When you assin a DateTime, a separate copy is created
	DateTime datecopy = date;  
	
	//The two structs have the same values
	Console.WriteLine(date);
	Console.WriteLine(datecopy);
	
	//The copy is not affected when the original changes
	date = DateTime.MinValue;
	Console.WriteLine(datecopy);  
	
}

// Define other methods and classes here
}