Of Code and Me

Somewhere to write down all the stuff I'm going to forget and then need

Display C# code in a WordPress Blog September 16, 2009

Filed under: Uncategorized — Rupert Bates @ 4:24 pm

A cool way to get WordPress to format and sytax highlight your C# code:

[sourcecode language=’csharp’]
string MyCode = “My Code”;
[/sourcecode]

Which appears in the post as:

string MyCode = "My Code";
Advertisements
 

8 Responses to “Display C# code in a WordPress Blog”

  1. dmidea Says:

    This doesn’t work for my post. Does anything i’m missing?

  2. dmidea Says:

    I solved by change the single quote to double quote. Thanks.

  3. Rupert Bates Says:

    Strange, single quotes works for me. Glad you got it working though

  4. rlee923 Says:

    Thanks for the post

  5. rlee923 Says:

    for some reason it doesn’t work for me..T_T
    I have put in on html view.

  6. […] just started to write a post and wanted to include some C#.  I found the solution here.  And here.  And here.  That last has a set of additional parameters you can use, including highlighting.  […]

  7. Michael McCarthy Says:

    when using these code blocks, my “” tags are being replaced with < and > whether I’m looking at the html or wysiswg view. Is this happening for anyone, and if so, is there a workaround. I’m getting tired of replacing these tags ever time I open up a draft blog to editing


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s