S
S
Sergey Karbivnichy2019-02-04 15:11:20
.NET
Sergey Karbivnichy, 2019-02-04 15:11:20

What can replace string interpolation in C# 5?

Interpolation has been available since C# 6. Are there any other ways to concatenate strings in C#5 other than this way:

public void Print(string str)
    {
      Console.WriteLine(DateTime.Now + str +" Ok!");
    }

It's easy to get confused.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Pavlov, 2019-02-04
@hottabxp

public void Print(string str)
{
      Console.WriteLine(string.Format("{0} {1} Ok!", DateTime.Now, str));
}

G
GavriKos, 2019-02-04
@GavriKos

There is string.Format, there is StringBuilder.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question