70 likes | 211 Views
Introduction to VC++.NET. #include”stdsfx.h” // includes contents of stdsfx.h into this program file #using <mscorlib.dll> // references prepackaged Microsoft code Using namespace System; // declares the use of namespace System. A simple program. Int _tmain() {
E N D
Introduction to VC++.NET • #include”stdsfx.h” • // includes contents of stdsfx.h into this program file • #using <mscorlib.dll> • // references prepackaged Microsoft code • Using namespace System; • // declares the use of namespace System
A simple program • Int _tmain() • { • Console::WriteLine(S”Welcome”); • // display a string • return 0 • }// end of _tmain
namespace • A namespace groups various MC++ features into related categories. • The namespace that are defined int the .NET Framework contain preexisting code known as the .NET Framework Class Library. • A example of one of the features in namespace System is class Console
Console class • The Console class enables programs to output information to the computer’s standard output. • Class Console provides methods, such as method WriteLine, that allow MC++ program to display strings and other types of information in the windows console window
S • The S prefix indicates that the string that follows is a string-literal in the Managed Extensions for C++ • Write(S” ..”); • WriteLine(S” …”); • ReadLine(); read a string from keyboard
Another example int _tmain() { String *Firstnum; String *Secondnum; int num1, num2, sum; Console::Write(S”Enter first integer”); Firstnum = Console::ReadLine(); Console::Write(S”Enter second integer”); Secondnum=Console::ReadLine(); num1 = Int32::Parse(Firstnum); num2 = Int32::Parse(Secondnum); sum = num1+num2; Console::WriteLine(S”\nThe sum is {0}.”, sum.ToString()); return 0; }
FCL Structure/class name • Int16 16 bit signed integer short • Int32 32-bit signed integer int • Int64 64-bit integer __int64 • Single 32-bit float • Double 64-bit double • Boolean boolean value bool • Char Unicode(16-bit)character • String string of unicode characters String*