Skip to content

Instantly share code, notes, and snippets.

@daneb
Created June 21, 2019 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daneb/85bd70dc0111f3663038e7e72eebe79b to your computer and use it in GitHub Desktop.
Save daneb/85bd70dc0111f3663038e7e72eebe79b to your computer and use it in GitHub Desktop.
Explicit Typing Linked to Blog Post
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