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 :: create list in c# 
Csharp :: c# edit element in list 
Csharp :: c# multi assignment 
Csharp :: datatable linq where clause c# 
Csharp :: datetime check null c# 
Csharp :: Customize yup number 
Csharp :: how to remove white spaces from string in c# 
Csharp :: C# monogodb 
Csharp :: c# for statement 
Csharp :: or c# 
Csharp :: c# load form 
Csharp :: split string c# 
Csharp :: mfind how many digits a number has c# 
Csharp :: how to get keyboard input in unity 
Csharp :: c# dictionary with multiple values 
Csharp :: c# run batch file 
Csharp :: how to print something in c# 
Csharp :: convert decimal to 2 decimal places c# 
Csharp :: how to change dictionary value in c# 
Csharp :: c# csvhelper 
Csharp :: c# delete files in directory and subdirectories 
Csharp :: how to make a string in c# 
Csharp :: C# short getter setter 
Csharp :: c# code to read txt file line by line and split 
Csharp :: unity game object remove parent 
Csharp :: get both item and index in c# 
Csharp :: unity gameobject find inactive 
Csharp :: to list c# 
Csharp :: c# best way to loop and remove 
Csharp :: c# get distinct values all fields from list 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =