Created
June 21, 2019 12:38
-
-
Save daneb/85bd70dc0111f3663038e7e72eebe79b to your computer and use it in GitHub Desktop.
Explicit Typing Linked to Blog Post
This file contains 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 ExplicitTyping | |
{ | |
// This would have failed in C# 1 and 2, prior to the introduction of var in 3.0 | |
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/var | |
[Fact] | |
public void ImplicitTypingWillFail() | |
{ | |
var s = "Hello"; | |
var x = s.Length; | |
var twiceX = x * 2; | |
} | |
[Fact] | |
public void ExplicitTypingSucess() | |
{ | |
string s = "Hello"; | |
int x = s.Length; | |
int twiceX = x * 2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment