C, C ++, C # in Visual Studio #

Source: Internet
Author: User

In addition to development. net, Visual StudioProgramC, C ++Code, Easy to use, such as smart intelligence and debugging. In this example, vs2005 is used to calculate a combination of two numbers in three languages.

C program

    • Create a C ++ Win32 console application
    • Add the source file, select C ++ code, and enter. c
    • Project properties-> Configuration properties-> C/C ++-> advanced, "compile as" select "compile as C code (/TC )"
Int Getsum ( Int A, Int B)
{
Return A + B;
}

VoidMain ()
{
Printf ("This is a standard C program! \ N");
Printf ("The sum is % d \ n", Getsum (6,9));
}

 

C ++ Program

    • Create a C ++ Win32 console application
# Include < Iostream >
Using   Namespace STD;

ClassSumc
{
Public:
IntA;
IntB;

IntGetsum ()
{
ReturnA+B;
}
};

Int Main ()
{
Cout < " This is a standard C ++ program! " < Endl;
Sumc OBJ;
OBJ. = 9 ;
OBJ. B = 6 ;
Cout < " The sum is " < OBJ. getsum () < Endl;
}

 

C # Program

    • Create a C # console application
Using System;
Using System. Collections. Generic;
Using System. text;

Namespace CSHARP
{
Class Program
{
Static   Void Main ( String [] ARGs)
{
Console. writeline ( " This is a C # program! " );
Sumc OBJ =   New Sumc ();
Console. writeline ( " The sum is "   + OBJ. getsum ( 9 , 6 ));
}
}
Class Sumc
{
Public   Int Getsum ( Int A, Int B)
{
Return A + B;
}
}
}

 

Demo: Download
In one solution, the three projects need to be debugged to start the project.

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.