Is there an equivalent of PHP's highlight_string function in C#?
It is not necessary to be a built-in function.
Edit: If not is there a good library for that?
Edit2: I really need a server side solution for that like PHP does.
Is there an equivalent of PHP's highlight_string function in C#?
It is not necessary to be a built-in function.
Edit: If not is there a good library for that?
Edit2: I really need a server side solution for that like PHP does.
Nope, certainly not in the Framework itself. You'd have to look for libraries that support this.
There's a list of syntax highlight plugins in javascript that you could use.
If you want it for webpages (which I assume, since the PHP highlight function formats it as HTML) you can use Googles Code prettify. It's however a javascript, which on the other hand makes it code-behind language independent.
I'm using it at my site with great success :-)
You can find it here: http://code.google.com/p/google-code-prettify/
There is nothing in the framework that will give you the coloured output. You will have to use a library to do this.
C# Code Format was one of the first .Net ones to come up in Google, although it only supports highlighting of C#, VB, HTML, XML, T-SQL or Monad. It is capable of running server side though as it is written in C#. If you need it to format PHP, then it is probably quite simple to extend it to do so - just make a custom PHPFormat class.
You can build yourself a basic syntax highlighter easy using RegExp.
Here's an example:
Or if you want a html C# highlighter written in C#
Or a JS highlighter:
A code formatter in csharp, note the link for sourcecode at the bottom. Hope that helps!