+ All Categories
Home > Documents > Visual Programming Fall 2012 – FUUAST Topic: Development environment.

Visual Programming Fall 2012 – FUUAST Topic: Development environment.

Date post: 29-Dec-2015
Category:
Upload: stephen-farmer
View: 215 times
Download: 0 times
Share this document with a friend
17
Visual Programming Fall 2012 – FUUAST Topic: Development environment
Transcript

Visual Programming

Fall 2012 – FUUAST

Topic: Development environment

What will we do today

• We will create windows applications• Introduction of .NET IDE• Namespace, Class, Object ,Function/Method,

Access modifiers ,Properties, Events.• Create first windows Application “Hello Wold”

Development environment• create windows applications

Development environment• create windows applications

Development environment• Design environment:

Toolbar

messagesProperties/events window

Code editorForm

Solution explorerMenus

Development environmentThe Form – Most important - place controls – the UI.

Display by clicking Form1.cs [Design] tab

Form

Textbox

Button

Label

Listbox

Development environment• Namespace- The namespace keyword is used to declare a scope. This namespace scope

lets you organize code and gives you a way to create globally unique types.

namespace BS5{public class Student { public void Get_Name() { } } public class Teacher { public void Get_Name() { } }}

- Whether or not you explicitly declare a namespace in a C# source file, the compiler adds a default namespace.

Development environment• Class- The class is the fundamental building block of code when creating object-

oriented software. - A class describes in abstract all of the characteristics and behavior of a type

of object. public class Student { public void Get_Name() { } }

• Object - Objects are instances of a class.- the class is just a definition. When the object is physically created, space for

that object is allocated in RAM. It is possible to have multiple objects created from one class.

Student Std = new Student();

Development environment• Function/Method- Classes contain methods that solve the problems for the program. So a

methods is a kind of building blocks that solve a small problem. public class Student { public void Get_Name() { } public void Calculate_Age_Number() { }

}

Development environment• Access Modifiers

Access modifiers are an integral part of object-oriented programming. They support the concept of encapsulation, which promotes the idea of hiding functionality. Access modifiers allow you to define who does or doesn't have access to certain features.

Modifier Description

public There are no restrictions on accessing public members.

private Access is limited to within the class definition. This is the default access modifier type if none is formally specified

protected Access is limited to within the class definition and any class that inherits from the class

internal Access is limited exclusively to classes defined within the current project assembly

protected internal Access is limited to the current assembly and types derived from the containing class. All members in current project and all members in derived class can access the variables.

Development environment• Events- Event is a method that contains the code that gets executed in response to

a specific event that occurs in an application. Event

Development environment• Properties- A property is a member that provides a flexible mechanism to read, write, or compute the value of a

private field. Properties can be used as if they are public data members.

class TimePeriod

{

private double seconds;

public double Hours

{

get { return seconds / 3600; }

set { seconds = value * 3600; }

}

}

class Program

{

static void Main()

{

TimePeriod t = new TimePeriod();

// Assigning the Hours property causes the 'set' accessor to be called.

t.Hours = 24;

// Evaluating the Hours property causes the 'get' accessor to be called.

System.Console.WriteLine("Time in hours: " + t.Hours);

}

}

// Output: Time in hours: 24

Development environment• Properties

Size (height and width)

Description of property

windows Application “Hello World”Your First C# Program • Run C#, start a new Project, > Windows Application and

call it ‘Hello world’ • Save the project. Select File>Save All. • Display the form (click form1.cs[Design] tab). • Add button (drag and drop) from Toolbox to form

windows Application “Hello World”Change the button’s text display (a property). Display the properties window, Scroll to the Text property, type in ‘Hello world’

windows Application “Hello World”Place TextBox and label to formChange label’s caption property to ‘My First C# Program’.Form looks like:

windows Application “Hello World”Run program – not much happens. Close it.Double-click button to add code for button clickAdd code:

textBox1.Text="Hello world";

Note: Use dot notation to access property C# is case sensitive.


Recommended