[Mono-list] Incorporate hexidecimal in C# string

Baltasar García Perez-Schofield baltasarq at gmail.com
Mon Oct 13 12:29:33 UTC 2014


>Please tell me how I would go about incorporating hex 0x02 and 0x03, Start
>Of Text and End of Text, into a string in C#.
>In C i would sprintf it but have as yet not found an equivalent in C#.
>In fact from the reading I have done I am no longer sure that C# can
>handle hex.

	You can use string.format. Instead of %s or %d, you use {0} or {1}, being that the position of the value in the data list. For example:

	string str = "...";
	string final = string.Format( "{0}{1}{2}", 0x02, str, 0x03 );


	format string:

Baltasar (baltasarq at gmail.com  http://baltasarq.info/)

More information about the Mono-list mailing list