TimeSpan t = cts - new DateTime(1, 1, 1); // calculate a timespan
int days = (int)t.TotalDays+1; // for casting to an integer
</syntaxhighlight>
=== Distinguish objects based on their MetaClass type? ===
If certain actions should only be executed for objects having a specific type, use the <code>is</code> keyword. This check also considers the inheritance.
<syntaxhighlight lang="csharp">
if (obj is UBIK.Runtime.AC_DOUBLE)
{
//do something
}
</syntaxhighlight>
[[Category:Best Practices (internal)|Coding Practices]]