Click here to Skip to main content
15,127,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am somewhat beginner in coding. My question seem easy, but...
I wrote an application to send some special text to a printer (a Zebra printer, the text is a ZPL code).

What I have tried:

I definded a string in the app combined with some variables.
My question is: there is the string with a variable:

"^FB330,1,,C^FO0,493^A0n,31,31^F8^FD" + LATK + "^FS"

I would like to put this string in a separate text file.
In the app I would like to read the text file, assign a value to the LATK variable from the text file, and then send it to the printer. The question is, how could I evaluate the string with the variables to get this


Appreciate any aswers.
Updated 13-Oct-20 11:32am

1 solution

The way I'd do it is to add format markers:
string putThisToFile = "fixed text:{0}:more fixed text";
string LATK = "variable text";
string result = string.Format(putThisToFile, LATK);

The result you get is:
fixed text:variable text:more fixed text

Make sense?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900