Last active
February 2, 2016 00:22
-
-
Save jmreynolds/cf1e483aa9d25dc76196 to your computer and use it in GitHub Desktop.
C# 6 Features: String Interpolation
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 Person | |
{ | |
public Person() | |
{ | |
PersonId = Guid.NewGuid(); | |
} | |
public Guid PersonId { get; set; } | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
} |
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 static void Main() | |
{ | |
var person = new Person(); | |
person.FirstName = "Joe"; | |
person.LastName = "Reynolds"; | |
var outputStr = "Person ID: " + person.PersonId + Environment.NewLine + | |
"Name: " + person.FirstName + " " + person.LastName; | |
Console.WriteLine(outputStr); | |
} |
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
using System; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
var person = new Person(); | |
person.FirstName = "Joe"; | |
person.LastName = "Reynolds"; | |
Console.WriteLine($"New Person ID: {person.PersonId}"); | |
Console.WriteLine($"New Name: {person.FirstName} {person.LastName}"); | |
Console.WriteLine("Did it work?"); | |
} | |
} |
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
using System; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
var person = new Person(); | |
person.FirstName = "Joe"; | |
person.LastName = "Reynolds"; | |
Console.WriteLine(string.Format("Person ID: {0}", person.PersonId.ToString())); | |
Console.WriteLine(string.Format("Name: {0} {1}", person.FirstName, person.LastName)); | |
Console.WriteLine("Did it work?"); | |
} | |
} |
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
static void Main(string[] args) | |
{ | |
string name = "Stranger"; | |
Console.WriteLine($"Howdy {name}"); | |
Console.ReadKey(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment