Domanda

I think I'm having a little problem because I'm confusing my terminology on this.

I need to wrap a string with a vertical tab (char)11 or (char)0x0b on the front and a (char)28 or (char)0x1c on the end.

Part of my confusion is I don't understand what the difference between the 11 and the 0x0b is. I believe one is ascii and one is hex, but I'm not positive. So essentially I need to do

string response = (char)0x0b + "message" + (char)0x1c;

That doesn't seem to work though.

È stato utile?

Soluzione

Part of my confusion is I don't understand what the difference between the 11 and the 0x0b is.

There is no difference. The two represent the same mathematical number eleven, expressing it using different base (base 16 for 0x0B, and base 10 for 11).

C# provides an escape sequence for the vertical tab - \v, so you could write '\v' in place of (char)0x0b. There is no escape sequence for 0x1C, but you can use a hexadecimal escape sequence to express it like \x1C.

The modified code would look like this:

string response = '\v' + message + 'x1C';

I removed the double-quotes around "message", assuming that it represents a string variable that your code has prepared before returning the response.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top