Interpolation string in C#

Interpolated string in C# that string that contains before it symbol $.

That interpolated string can contain special expressions inside in curly braces:

int x = 18;
Console.Write($"Указанный возраст {x} лет."); // Выводит: Указанный возраст 18 лет.

Inside the curly braces can be placed any acceptable expressions C# of any type. C# do transform some value to string, using ToString() method or equivalent for chosen type.

Output format can be changed by add colon and then string format expression, for example:

string s = $"223 in HEX format: {223:X2}"; // X2 - Two digit HEX formatted number.
// Result "223 in HEX format: DF"
Read more

Example of converting XML into DYNAMIC and use it.

Example of converting XML into DYNAMIC and use it.

For begin we need some libraries:

using System;
using System.ComponentModel;
using System.Xml.Linq;
using Newtonsoft.Json;


string str = "<response><setter><name>Kiril</name></setter></response>";
XDocument doc = XDocument.Parse(str);
string jsn = JsonConvert.SerializeXNode(doc);
dynamic res = JsonConvert.DeserializeObject(jsn);


That code convert string to XML, then XML to JSON and then convert it to dynamic object.
After that, from dynamic object it get Name property and send it ti console.

Read more