How can I escape block string to add byte in to it as byte

ProtekNickz

Member
Joined
Jan 13, 2022
Messages
14
Programming Experience
5-10
Hi their,
I have a block string of code in my program, and I'm trying to Escape a portion of it to add a byte in so when the block string is run the data in the byte is compiled with the block string,

Block String:
string MyCollectiveStrings =
     @"
            using System.Linq;
            using System;
            using System.Windows.Forms;
            using System.Diagnostics;
            using Microsoft.Win32;
            using System.Reflection;
            using System.Runtime.InteropServices;

            namespace ProgramName
    {
        class Program
        {
            byte[] bytesOne = " + myBytesOne + @";
            byte[] bytesTwo = " + myBytesTwo + @";

            static void Main(string[] args)
            {
            //TODO
            //Code here will write bytes to a single file a sort of Append
            }
        }
    }";

the problem is it's handling my myBytesOne & myBytesTwo as strings which I don't want, is their away to escape the block string and add in the bytes as bytes in between the line and carry on the block string?

Cheers in advance.

ProtekNickz :).
 
Just use string interpolation so that you don't need to use string concatenation.

I vaguely recall that you had reason for not using CodeDom (and I don't blame you), but another thing you can look at is using T4 templates at runtime.
 
Back
Top Bottom