Skip to content

Instantly share code, notes, and snippets.

@Vannevelj
Last active January 27, 2016 19:06
Show Gist options
  • Save Vannevelj/3e3d3b9a0fc4391c046e to your computer and use it in GitHub Desktop.
Save Vannevelj/3e3d3b9a0fc4391c046e to your computer and use it in GitHub Desktop.
class MyClass
{
private int oAsInt32;
void Method(object o)
{
var oAsInt32 = o as int?;
if (oAsInt32 != null)
{
Console.Write(oAsInt32.Value);
} else {
Console.Write(this.oAsInt32);
}
}
}
class MyClass
{
private int oAsInt32;
void Method(object o)
{
if (o is int)
{
Console.Write((int) o);
} else {
Console.Write(oAsInt32);
}
}
}
class MyClass
{
private int oAsInt32;
void Method(object o)
{
var oAsInt32 = o as int?;
if (oAsInt32 != null)
{
Console.Write(oAsInt32.Value);
} else {
Console.Write(oAsInt32);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment