0

trying o use concatenation programming... instead of saying

UpdatePLOF.FolderPath = "PLOF" + plof.Id + ".txt";

trying something like:

UpdatePLOF.FolderPath = "PLOF {0} .txt", plof.Id;

for PLOF {0} .txt is telling me only assignment, call, increment etc... for plof.id it is telling me ; is needed

John
  • 3,965
  • 21
  • 77
  • 163

2 Answers2

5

You need a String.Format

UpdatePLOF.FolderPath = string.Format("PLOF {0} .txt", plof.Id);
Dave Bish
  • 19,263
  • 7
  • 46
  • 63
0

There are several ways to concatenate strings in C# and .NET.

String.Format is nice for when you'd like to be able to see what the resultant string will look like. However, it is significantly slower than the + operator, which the compiler can convert to String.Concat. String.Format has the extra overhead of having to parse the format string. In your case, it's probably a micro-optimization, but it's something to be aware of.

NathanAldenSr
  • 7,841
  • 4
  • 40
  • 51