Created
April 19, 2020 10:09
-
-
Save BanksySan/86b06b25501f9fbeda9cb29eb0ffd3e1 to your computer and use it in GitHub Desktop.
Casting Performance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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