Simple online C # IDE Example

Source: Internet
Author: User
Tags tostring

51 o'clock to a friend, he asked a little question, just write dozens of lines of code can be a good illustration of the problem. But the machine is not installed VS, had to do. When you come back, think about it, if you have an online c#ide. So the internet to check the relevant information, the whole out a simple online c#ide.

To do this, mainly to solve two problems, first, if the text box on the page to compile and execute the code, the second is if the program to run the results of the output on the Web page.

The first question is not difficult. NET already has ready-made C # compile class CSharpCodeProvider (or other language), then use CompilerParameters class as compile parameter, can easily realize.

The second question, in the simplest case, is to display the content of the Console.Write method output on the Web page. This is also very good to do, as long as the output statement before compiling a replacement, the output of the content to save to another place. When the run is over, take it out of the place.

The code implementation is as follows:

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Vsonline.framework
{
/**////<summary>
Custom Output Classes
</summary>
public class Consoler
{
Store all output
public static dictionary<string, consoler> outputs {get; set;}
Static Consoler ()
{
outputs = new dictionary<string, consoler> ();
}
Output Operation #region Output operation
Current output
Public list<string> Output {get; private set;}
Public Consoler ()
{
Output = new list<string> ();
}
public void Write (Object str)
{
Output.add (str. ToString ());
}
public void WriteLine (Object str)
{
Output.add (str. ToString () + "\ n");
}
#endregion
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.