Skip to content

Instantly share code, notes, and snippets.

@BanksySan
Created April 19, 2020 10:09
Show Gist options
  • Save BanksySan/86b06b25501f9fbeda9cb29eb0ffd3e1 to your computer and use it in GitHub Desktop.
Save BanksySan/86b06b25501f9fbeda9cb29eb0ffd3e1 to your computer and use it in GitHub Desktop.
Casting Performance
public class Casting
{
private Child _child;
private Parent _parent;
[GlobalSetup]
public void GlobalSetup()
{
_parent = new Parent();
_child = new Parent();
}
[Benchmark]
public Child Implicit()
{
return _parent;
}
[Benchmark]
public Parent Explicit()
{
return (Parent)_child;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment