Web Applications Stack Exchange is a question and answer site for power users of web applications. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I format my C# code so it displays correctly in our internal Wiki?

We are using MediaWiki although I assume most wiki syntax is the same.

share|improve this question

migrated from superuser.com Oct 26 '11 at 20:07

This question came from our site for computer enthusiasts and power users.

Formatting the C# code that way will make that C# code not compilable. Is this OK? – m0skit0 Oct 26 '11 at 8:58
up vote 4 down vote accepted

If you are using the GeShi syntax highlighting extension to MediaWiki, then you can just insert your C♯ code as-is, enclosed within a <syntaxhighlight/> element. (This is, as you can see from the syntax highlighting extensions category, one of several such MediaWiki extensions.)

The MediaWiki wikis used, by the Wikimedia Foundation, for Wikipedia, Wiktionary, Wikibooks, Wikiquote, et al. all have this extension enabled. Here is some wikitext taken directly from the current (at the time of writing) Wikipedia article for C♯ (q.v.) that exemplifies what the wikitext looks like:

<syntaxhighlight lang=CSharp>
// Declare the generic class.

public class GenericList<T>
    void Add(T input) { }

class TestGenericList
    private class ExampleClass { }
    static void Main()
        // Declare a list of type int.
        GenericList<int> list1 = new GenericList<int>();

        // Declare a list of type string.
        GenericList<string> list2 = new GenericList<string>();

        // Declare a list of type ExampleClass.
        GenericList<ExampleClass> list3 = new GenericList<ExampleClass>();

See the Wikipedia article for how this wikitext is rendered.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.