CRL Via C # uses CSC.exe to compile two of files

Source: Internet
Author: User


1. Create a new Calculator.cs file

The code is as follows

Using System;namespace myclasslib{public class Calculator {public int Add (int a, int b) {        return a + B;        } public int Sub (int a, int b) {return a-A; }    }}

2, compile the Calculator.cs, generate the MyClassLib.dll file

Csc.exe/out:myclasslib.dll/t:library Calculator.cs

/t:library is to generate a class library file

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7D/C3/wKioL1bvozXSif3NAAAidUlXhmA992.png "title=" Calculator_cs_lib.png "alt=" Wkiol1bvozxsif3naaaidulxhma992.png "/>


3. Create a new Program.cs file


The code is as follows

Using system;using myclasslib;namespace myconsoleapp{    class program     {        static void main (string[]  args)         {                         console.write ( "Please enter the first integer:");             int number1 =  convert.toint32 (Console.ReadLine ());             console.write ("Please enter a second integer:");             int  number2 = convert.toint32 (Console.ReadLine ());             calculator cal = new calculator ();         &nbsP;   console.writeline ("{0} + {1} = {2}", number1,number2,cal. ADD (number1,number2));             Console.WriteLine ("{0} - {1} = {2}",  number1, number2, cal. Sub (number1, number2));             Console.readkey ();         }    }}

4, compile the Program.cs, generate the Program.exe file

Csc.exe/out:program.exe/t:exe/r:myclasslib.dll Program.cs


/r:myclasslib.dll is a reference to the. dll file


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7D/C3/wKioL1bvpdqwaufIAAAzx2567is495.png "title=" Program_cs_exe.png "alt=" Wkiol1bvpdqwaufiaaazx2567is495.png "/>

5. Program Operation result

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7D/C7/wKiom1bvpXDCnrmTAAAHbrFlNeA966.png "title=" Program_exe_result.png "alt=" Wkiom1bvpxdcnrmtaaahbrflnea966.png "/>






CRL Via C # uses CSC.exe to compile two of files

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.