C++ Windows Forms L01 - Intro

93
Mohammad Shaker mohammadshakergtr.wordpress.com C++.NET Windows Forms Course @ZGTRShaker C++.NET Windows Forms Course L01 - Introduction

description

C++ Windows Forms L01 - Intro of C++ Windows Forms Light Course

Transcript of C++ Windows Forms L01 - Intro

Page 1: C++ Windows Forms L01 - Intro

Mohammad Shakermohammadshakergtr.wordpress.com

C++.NET Windows Forms Course@ZGTRShaker

C++.NET Windows Forms Course

L01 - Introduction

Page 2: C++ Windows Forms L01 - Intro

.NET \ What will you learn?

• OOP with .NET, Thinking OOP and The Concept of .NET• Peek on C++.NET console• Debugging in .NET• Windows Forms Controls (Tabs, ComboBox, Timers, ...etc)• Drawing with .NET• Collections

Page 3: C++ Windows Forms L01 - Intro

.NET \ What will you learn?

• Event Handling • Exception Handling • Files processing - Strings Manipulating• Dynamic Controls associated with Event Handling• The Concept of C#

Page 4: C++ Windows Forms L01 - Intro

What’s .NET?

• .NET Framework :– A collection of technologies that …

• Unite isolated applications• Make information available anytime, anywhere• Simplify development and deployment

Page 5: C++ Windows Forms L01 - Intro

What’s .NET?

• .NET Framework :– Common Language Runtime* – provides an abstraction layer over the

operating system– Base Class Libraries

• pre-built code for common low-level programming tasks

– Development frameworks and technologies • Reusable• customizable solutions for larger programming tasks

_________________________________________________

*The Common Language Runtime (CLR) is the virtual machine component of the .NET Framework. All .NET programs execute under the supervision of the CLR, guaranteeing certain properties and behaviors in the areas of memory management, security, and exception handling.

Page 6: C++ Windows Forms L01 - Intro

Some .NET Base Class Libraries

System

System.Data System.Xml

System.Web

Globalization

Diagnostics

Configuration

Collections

Resources

Reflection

Net

IO

Threading

Text

ServiceProcess

Security

Design

ADO

SQLTypes

SQL

XPath

XSLT

RuntimeInteropServices

Remoting

Serialization

Serialization

Configuration SessionState

Caching Security

ServicesDescription

Discovery

Protocols

UI

HtmlControls

WebControls System.Drawing

Imaging

Drawing2D

Text

Printing

System.WinForms

Design ComponentModel

Page 7: C++ Windows Forms L01 - Intro

.NET Platform

Man

age

and

Col

labo

rate

Deployment

Testing

Development

Design

Analysis

Planning

Visual Studio® .NET

Page 8: C++ Windows Forms L01 - Intro

.NET Framework, Languages, Tools

Base Class Library

Common Language Specification

Common Language Runtime

Data and XML

VB C++ C#V

isual Studio .NET

WebServices

JScript …

UserInterface

Page 9: C++ Windows Forms L01 - Intro

Common Language Runtime

Class Loader

IL to NativeCompilers

CodeManager

GarbageCollector

Security Engine Debug Engine

Type Checker Exception Manager

Thread Support COM Marchaler

Base Class Library Support

Page 10: C++ Windows Forms L01 - Intro

.NET Framework Services

ASP.NET Logical evolution of ASP (compiled)

Web forms Manageable code (non spaghetti)

Windows® forms Framework for building rich clients

ADO.NET, evolution of ADO New objects (e.g., DataSets)

XML Support Throughout

Page 11: C++ Windows Forms L01 - Intro

Introduction to .NET

Page 12: C++ Windows Forms L01 - Intro

Introduction to .NET

• The .NET Framework allows you to:– Apply common skills across a variety of devices , application types ,

and programming tasks– Integrate with other tools and technologies to build the right

solution with less work– Build compelling applications faster

• .NET Framework releases :– 1 , 1.1 , 2 , 3 , 3.5 , 4, 4.5

Page 13: C++ Windows Forms L01 - Intro
Page 14: C++ Windows Forms L01 - Intro
Page 15: C++ Windows Forms L01 - Intro

.NET IDE and Frameworks

• .NET With Visual Studio 2008 \ 2010 \ 2012 \ 2013• Framework 3.5 \ 4.0 \ 4.5

Page 16: C++ Windows Forms L01 - Intro

Resources for .NET

http://www.w3.org/TR/SOAP/ - W3C standards for SOAP implementation http://www.uddi.org – UDDI standards for web services implementation http://www.microsoft.com/net - Microsoft .NET home http://msdn.microsoft.com/net - Microsoft .NET developers home http://msdn.microsoft.com/xml - Microsoft XML developers home http://msdn.microsoft.com/webservices – Microsoft Web Services developers home

http://www.gotdotnet.com – Developers .NET resource

Page 17: C++ Windows Forms L01 - Intro
Page 18: C++ Windows Forms L01 - Intro

Controls

• Form• Button• CheckBox• CheckedListBox• ComboBox• Label• ListBox• PictureBox

• ProgressBar• RadioButton• TextBox• Panel• TabControl• DataGridView• Timer

Page 19: C++ Windows Forms L01 - Intro

Con.sole

Page 20: C++ Windows Forms L01 - Intro

Console

Page 21: C++ Windows Forms L01 - Intro
Page 22: C++ Windows Forms L01 - Intro

Console

Page 23: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

return 0;

}

Page 24: C++ Windows Forms L01 - Intro

Console

Page 25: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 26: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 27: C++ Windows Forms L01 - Intro

Console

What’s this?// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 28: C++ Windows Forms L01 - Intro

Console

What a “namespace” is?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 29: C++ Windows Forms L01 - Intro

Console

Why using another namespace?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 30: C++ Windows Forms L01 - Intro

Console

“main”Why?

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 31: C++ Windows Forms L01 - Intro

Console

Why isn’t it just a void?!Why passing a string “args”

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 32: C++ Windows Forms L01 - Intro

Console

Easy, right?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 33: C++ Windows Forms L01 - Intro

Console

What’s that?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 34: C++ Windows Forms L01 - Intro

Console

Object/Class// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 35: C++ Windows Forms L01 - Intro

Console

“::” ?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 36: C++ Windows Forms L01 - Intro

Console

Console::WriteLine// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 37: C++ Windows Forms L01 - Intro

Console

Console::WriteLine// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 38: C++ Windows Forms L01 - Intro

Console

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console ^myConsole=gcew Console();

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 39: C++ Windows Forms L01 - Intro

Console

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console ^myConsole=gcew Console();

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 40: C++ Windows Forms L01 - Intro

Console

Creating an instance of class “Console”// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console ^myConsole=gcew Console();

Console::WriteLine(L"Hello World");

Console::ReadKey();

return 0;

}

Page 41: C++ Windows Forms L01 - Intro
Page 42: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::Write("Hi, again!");

Console::WriteLine("\n Hi, again!");

Console::Write("Hi, again!");

Console::ReadKey();

return 0;

}

Page 43: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

Console::WriteLine(L"Hello World");

Console::Write("Hi, again!");

Console::WriteLine("\n Hi, again!");

Console::Write("Hi, again!");

Console::ReadKey();

return 0;

}

Hello World

Hi, again!

Hi, again!

Hi, again!

Page 44: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str1=gcnew String("Hi Hi Hi, first time.");

String ^str2="Hi Hi Hi, second time.";

String ^str3;

Console::Write("Enter your name plz: ");

str3=Console::ReadLine();

Console::WriteLine(str1 + " " + str2 + " Hi " + str3 + "!");

Console::ReadKey();

return 0;

}

Page 45: C++ Windows Forms L01 - Intro

Console

Everything is dynamically allocated through pointer!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str1=gcnew String("Hi Hi Hi, first time.");

String ^str2="Hi Hi Hi, second time.";

String ^str3;

Console::Write("Enter your name plz: ");

str3=Console::ReadLine();

Console::WriteLine(str1 + " " + str2 + " Hi " + str3 + "!");

Console::ReadKey();

return 0;

}

Page 46: C++ Windows Forms L01 - Intro

Console

Why no gcnew here?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str1=gcnew String("Hi Hi Hi, first time.");

String ^str2="Hi Hi Hi, second time.";

String ^str3;

Console::Write("Enter your name plz: ");

str3=Console::ReadLine();

Console::WriteLine(str1 + " " + str2 + " Hi " + str3 + "!");

Console::ReadKey();

return 0;

}

Page 47: C++ Windows Forms L01 - Intro

Console

Why no gcnew here?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str1=gcnew String("Hi Hi Hi, first time.");

String ^str2="Hi Hi Hi, second time.";

String ^str3;

Console::Write("Enter your name plz: ");

str3=Console::ReadLine();

Console::WriteLine(str1 + " " + str2 + " Hi " + str3 + "!");

Console::ReadKey();

return 0;

}

Page 48: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str1=gcnew String("Hi Hi Hi, first time.");

String ^str2="Hi Hi Hi, second time.";

String ^str3;

Console::Write("Enter your name plz: ");

str3=Console::ReadLine();

Console::WriteLine(str1 + " " + str2 + " Hi " + str3 + "!");

Console::ReadKey();

return 0;

}

Page 49: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str1=gcnew String("Hi Hi Hi, first time.");

String ^str2="Hi Hi Hi, second time.";

String ^str3;

Console::Write("Enter your name plz: ");

str3=Console::ReadLine();

Console::WriteLine(str1 + " " + str2 + " Hi " + str3 + "!");

Console::ReadKey();

return 0;

}

Page 50: C++ Windows Forms L01 - Intro

Console

Returns the string that’s read from the input buffer// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str1=gcnew String("Hi Hi Hi, first time.");

String ^str2="Hi Hi Hi, second time.";

String ^str3;

Console::Write("Enter your name plz: ");

str3=Console::ReadLine();

Console::WriteLine(str1 + " " + str2 + " Hi " + str3 + "!");

Console::ReadKey();

return 0;

}

Page 51: C++ Windows Forms L01 - Intro

Console

Returns the string that’s read from the input buffer// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str1=gcnew String("Hi Hi Hi, first time.");

String ^str2="Hi Hi Hi, second time.";

String ^str3;

Console::Write("Enter your name plz: ");

str3=Console::ReadLine();

Console::WriteLine(str1 + " " + str2 + " Hi " + str3 + "!");

Console::ReadKey();

return 0;

}

Page 52: C++ Windows Forms L01 - Intro

Console

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i.ToString() + f.ToString());

Console::ReadKey();

return 0;

}

Page 53: C++ Windows Forms L01 - Intro

Console

It’s not a “->”

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i.ToString() + f.ToString());

Console::ReadKey();

return 0;

}

Page 54: C++ Windows Forms L01 - Intro

Console

Where this method “ToString()” comes from?!

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i.ToString() + f.ToString());

Console::ReadKey();

return 0;

}

Page 55: C++ Windows Forms L01 - Intro

Console

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i.ToString() + f.ToString());

Console::ReadKey();

return 0;

}

10

Page 56: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 57: C++ Windows Forms L01 - Intro

Console

No “ToString()” method!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 58: C++ Windows Forms L01 - Intro

Console

How compiler works?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 59: C++ Windows Forms L01 - Intro

Console

How compiler works?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 60: C++ Windows Forms L01 - Intro

Console

How compiler works?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 61: C++ Windows Forms L01 - Intro

Console

How compiler works?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 62: C++ Windows Forms L01 - Intro

Console

How compiler works?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 63: C++ Windows Forms L01 - Intro

Console

How compiler works?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 64: C++ Windows Forms L01 - Intro

Console

How compiler works?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 65: C++ Windows Forms L01 - Intro

Console

How compiler works?!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 66: C++ Windows Forms L01 - Intro

Console

Arithmetic “Sum”!// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 67: C++ Windows Forms L01 - Intro

Console

Results a “float”// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 68: C++ Windows Forms L01 - Intro

Console

Results a “float”in a “String” context

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 69: C++ Windows Forms L01 - Intro

Console

Results a “float”in a “String” context

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

Page 70: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

float f=0;

Console::WriteLine(i + f);

Console::ReadKey();

return 0;

}

1

Page 71: C++ Windows Forms L01 - Intro

Console (Types Conversion)// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

String ^str=i.ToString();

Console::WriteLine(str);

Console::ReadKey();

return 0;

}

Page 72: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

int i=1;

String ^str=i.ToString();

Console::WriteLine(str);

Console::ReadKey();

return 0;

}

1

Page 73: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str="1123";

int i=Int32::Parse(str);

i++;

Console::WriteLine(i);

Console::ReadKey();

return 0;

}

Page 74: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str="1123";

int i=Int32::Parse(str);

i++;

Console::WriteLine(i);

Console::ReadKey();

return 0;

}

1124

Page 75: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str="1123";

int i=0;

Int32::TryParse(str,i);

i++;

Console::WriteLine(i);

Console::ReadKey();

return 0;

}

Page 76: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str="1123";

int i=0;

Int32::TryParse(str,i);

i++;

Console::WriteLine(i);

Console::ReadKey();

return 0;

}

1124

Page 77: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str="1123ccccc";

int i=0;

Int32::TryParse(str,i);

i++;

Console::WriteLine(i);

Console::ReadKey();

return 0;

}

Page 78: C++ Windows Forms L01 - Intro

Console// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)

{

String ^str="1123ccccc";

int i=0;

Int32::TryParse(str,i);

i++;

Console::WriteLine(i);

Console::ReadKey();

return 0;

}

1

Page 79: C++ Windows Forms L01 - Intro

Arrays

Page 80: C++ Windows Forms L01 - Intro
Page 81: C++ Windows Forms L01 - Intro

Arrays

• Defining an array of string with dimension of 3

public : array <String^ , 3 > ^MyArr;

Page 82: C++ Windows Forms L01 - Intro

Arrays

• Defining an array of string with dimension of 3

• Everything okay?

Both are Compiler Errors!

public : array <String^ , 3 > ^MyArr;

public : array <String^ , 3 > MyArr;

public : array <String , 3 > ^MyArr;

Page 83: C++ Windows Forms L01 - Intro

Arrays

• Sth wrong?

array <String ^ , 1 > ^MyArr;

MyArr[0][0]="1";

Compiler error

array <String ^ , 1 > ^MyArr;

MyArr[0]=1;

Compiler error

array <String ^ , 2> ^MyArr;

MyArr=gcnew array <String^ , 2 > (100,50);

MyArr[0,0]="1";

Everything is good

Page 84: C++ Windows Forms L01 - Intro

Arrays

• Sth wrong?array <String ^ , 2> ^MyArr;

MyArr=gcnew array <String^ > (100,50);

MyArr[0,0]="1";

Compiler error

array <String ^ , 2> ^MyArr;

MyArr=gcnew array <String^ , 2 > (100,50);

MyArr[0][0]="1";

Compiler error

array <String ^ , 2> ^MyArr;

MyArr=gcnew array <String^ , 2 > (100)(50);

MyArr[0,0]="1";

Compiler error

Page 85: C++ Windows Forms L01 - Intro

Arrays

• Sth wrong?

array <String ^> ^MyArr;

MyArr=gcnew array <String^ > (50);

MyArr[0]="1";

Everything is good

Page 86: C++ Windows Forms L01 - Intro

Arrays

Page 87: C++ Windows Forms L01 - Intro

Arrays

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args){

array <String ^ , 1 > ^MyArr; MyArr[0]="1";

Console::ReadKey();return 0;

}

Page 88: C++ Windows Forms L01 - Intro

Arrays

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args){

array <String ^ , 1 > ^MyArr; MyArr[0]="1";

Console::ReadKey();return 0;

}

Ntn wrong!

Page 89: C++ Windows Forms L01 - Intro

Arrays

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args){

array <String ^ , 1 > ^MyArr; MyArr[0]="1";

Console::ReadKey();return 0;

}

Ntn wrong!

Page 90: C++ Windows Forms L01 - Intro

Arrays

// CppdotNetConsoleCourseTest.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args){

array <String ^ , 1 > ^MyArr; MyArr[0]="1";

Console::ReadKey();return 0;

}

Ntn wrong!

Page 91: C++ Windows Forms L01 - Intro

Arrays

• Considering that we have a class named “CELL”array <CELL^ , 2> ^MyArr;

MyArr=gcnew array <CELL^ , 2 > (100,50);

CELL ^MyCell=gcnew CELL;

MyArr[0,0]=MyCell;

Page 92: C++ Windows Forms L01 - Intro

Arrays

• Considering that we have a class named “CELL”array <CELL^ , 2> ^MyArr;

MyArr=gcnew array <CELL^ , 2 > (100,50);

CELL ^MyCell=gcnew CELL;

MyArr[0,0]=MyCell;

Page 93: C++ Windows Forms L01 - Intro

That’s it for today!