Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visual Programming Fall 2012 – FUUAST Topic: Development environment.

Similar presentations


Presentation on theme: "Visual Programming Fall 2012 – FUUAST Topic: Development environment."— Presentation transcript:

1 Visual Programming Fall 2012 – FUUAST Topic: Development environment

2 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”

3 Development environment create windows applications

4 Development environment create windows applications

5 Development environment Design environment: Toolbar messages Properties/events window Code editor Form Solution explorer Menus

6 Development environment The Form – Most important - place controls – the UI. Display by clicking Form1.cs [Design] tab Form Textbox Button Label Listbox

7 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.

8 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();

9 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() { } }

10 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. ModifierDescription publicThere are no restrictions on accessing public members. privateAccess is limited to within the class definition. This is the default access modifier type if none is formally specified protectedAccess is limited to within the class definition and any class that inherits from the class internalAccess is limited exclusively to classes defined within the current project assembly protected internalAccess 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.

11 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

12 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

13 Development environment Properties Size (height and width) Description of property

14 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

15 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’

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

17 windows Application “Hello World” Run program – not much happens. Close it. Double-click button to add code for button click Add code: textBox1.Text="Hello world"; Note: Use dot notation to access property C# is case sensitive.


Download ppt "Visual Programming Fall 2012 – FUUAST Topic: Development environment."

Similar presentations


Ads by Google