Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

string interpolation in c#

var title = String.Format("{0} ({1})", post.Title, post.Comments.Count); 
//C# 6 introduces a beautiful way to write the same code in a more direct way:
var title = $"{post.Title} ({post.Comments.Count})";
Comment

c# use string in interpolation expression

string name = "Mark";
var date = DateTime.Now;

Console.WriteLine($"Hello, {name}! Today is {date.DayOfWeek}, it's {date:HH:mm} now.");
Console.WriteLine($"I have {2*2} apples");

// For ternary or "" add ()
Console.WriteLine($"I have a very cute {(true ? "cat": "dog")}");
Comment

c# string interpolation

var apples = 4;
var bananas = 3;

Console.WriteLine($"I have {apples} apples");
Console.WriteLine($"I have {apples + bananas} fruits");
Comment

string interpolation in C#

string foo = "bar";
Console.WriteLine($"{foo}") // prints "bar"
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# float 
Csharp :: how to get the today date in c# 
Csharp :: c# static 
Csharp :: c# clear console read chache 
Csharp :: c# xmldocument from file 
Csharp :: foreach c# linq example 
Csharp :: unity get audio clip length 
Csharp :: how to set a tag in asp net razor view stackoverflow 
Csharp :: substring in c# 
Csharp :: c# caractère cacher mot de passe 
Csharp :: run dll file 
Csharp :: int array to frequency dictionary c# 
Csharp :: csharp 3d array length 
Csharp :: unity draw waypoints path 
Csharp :: instantiate type c# 
Csharp :: cache trong mvc 
Csharp :: c# convert string to datetime dd-mm-yyyy hh-mm-ss 
Csharp :: Formcollection asp.net form 
Csharp :: unity cannot click button 
Csharp :: c# enum get string value 
Csharp :: c# asp.net hover tooltip 
Csharp :: remove substring from string c# 
Csharp :: w3develops 
Csharp :: select a whole row out of a 2d array C# 
Csharp :: c# float min value 
Csharp :: how to get gravity from Rigidbody2D in c# 
Csharp :: c sharp async 
Csharp :: c# split string 
Csharp :: reflection get enum value C# 
Csharp :: c# reverse a string for loop 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =