Here's a piece of code for obtaining the time when a .NET assembly was built. Note this line:
int secondsSince1970 = System.BitConverter.ToInt32(b, i + c_LinkerTimestampOffset);
this code extracts the TimeDateStamp
member of IMAGE_FILE_HEADER
structure that is stored inside the assembly. The structure is defined as follows:
typedef struct _IMAGE_FILE_HEADER {
WORD Machine;
WORD NumberOfSections;
DWORD TimeDateStamp;
DWORD PointerToSymbolTable;
DWORD NumberOfSymbols;
WORD SizeOfOptionalHeader;
WORD Characteristics;
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
and DWORD
is defined as follows:
typedef unsigned long DWORD;
and the struct description says that TimeDateStamp
is a number of seconds since an arbitrary moment in the past, so it can't be negative.
Why does the C# code use signed type int
to store that unsigned value?