[Mono-list] Incorporate hexidecimal in C# string

Slide slide.o.mix at gmail.com
Mon Oct 13 13:14:35 UTC 2014


On Mon, Oct 13, 2014 at 5:29 AM, Baltasar García Perez-Schofield <
baltasarq at gmail.com> wrote:

>
>
>         Hi,
>
> >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 );
>
>         string.Format:
>         http://msdn.microsoft.com/en-us/library/b1csw23d(v=vs.110).aspx
>
>         format string:
>         http://msdn.microsoft.com/en-us/library/txafckwd(v=vs.110).aspx
>
> --
> Baltasar (baltasarq at gmail.com  http://baltasarq.info/)
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>


I've found this page (http://blog.stevex.net/string-formatting-in-csharp/)
to be a good resource over the years if you want to learn more about the
different formatting options in a bit more user friendly manner.

slide

-- 
Website: http://earl-of-code.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20141013/fa9b32a8/attachment.html>


More information about the Mono-list mailing list