Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 3328 Object Oriented Programming in C# Chapter 1: Introduction to C# UTPA – Fall 2012 This set of slides is revised from lecture slides of Prof.

Similar presentations


Presentation on theme: "CSCI 3328 Object Oriented Programming in C# Chapter 1: Introduction to C# UTPA – Fall 2012 This set of slides is revised from lecture slides of Prof."— Presentation transcript:

1 CSCI 3328 Object Oriented Programming in C# Chapter 1: Introduction to C#
UTPA – Fall 2012 This set of slides is revised from lecture slides of Prof. John Abraham. -- Xiang Lian

2 Objectives In this chapter, you will Know requirements of this course
Recall basic components in a computer system Learn the evolution of programming language Refresh your memory about the object-oriented programming Become aware of the .NET Framework for Visual C#

3 Background Required Thorough C++ programming
If you made an A in 1370/1170 you will do fine with some effort If you have already taken 2380, you will find this course not very difficult You need to be able to look up how to get things done (example, look up syntax)

4 Programming, Programming, Programming
This class is unlike other courses in that you will spend a lot of time doing actual programming You should never copy a program from someone else Even if your program does not perform as good as someone else’s, you should submit what you have You should not hesitate to ask questions in class

5 Assignments Unless I announce it, programs are due in one week after assignment is given in class, or posted Occasionally, I will give two weeks for difficult programs You should work on a program the same day it is assigned That way you can ask questions during the following class period

6 Use of the Textbook I will not be covering chapter by chapter
I will cover important points needed to complete the assignments You need to search the index in the back to find the topic needed for each assignment You can also obtain help from MSDN at the Microsoft site

7 Versions of C# You can program using 2008 or 2010
Our book only covers 2008 Usually it takes a year or so for new books to come out If you use 2010, you have to find help from other sources or the Web

8 The Time for Class I expect to hold the class for little over an hour each time Remaining time should be spend with your assigned groups to discuss the project in class Please do not exchange programs with each other, just ideas

9

10 CSCI 1380: Elements of a Computer System
Hardware CPU Main memory Secondary storage Input / Output devices Software System programs Application programs (e.g. Visual Studio)

11 Programming Languages
Machine language Assembly language High-level language E.g., C#

12 Object Technology We humans are very good in recognizing and working with objects, such as a pen, a dog, or a human being We learned to categorize them in such a way that make sense to us. We may categorize them as animate object, inanimate objects, pets, friends, etc.

13 Object Technology (cont'd)
We some times classify objects based on their attributes, for example, green apples or red apples, fat or slim people, etc. If you think about it each object has many attributes. If I ask you list the attributes of an orange, you probably could list many things such as color, shape, weight, smell, etc.

14 Object Technology (cont'd)
In addition to attributes, all objects exhibit behaviors. A dog eats, barks, wags its tail, plays, and begs. A dog exhibits many more other behaviors than this short list. Another thing we need to remember about objects is that objects interact between each other

15 Object Technology in Visual C#
Object-oriented E.g. forms, labels, buttons, radios, checkboxes, etc. Properties of objects E.g. background color of forms Event-driven Behaviors  events of objects E.g. clicks

16 .Net Framework A software platform Language-neutral
Designed for cross-language compatibility Applications written in C# may reference a DLL file written in any other language 2 components: Common Language Runtime (CLR) Class Libraries

17 The .Net Framework Underneath the applications you develop using C# is the .Net Framework containing a library of classes needed for windows forms and web forms. The .Net framework interacts with the Common Language Runtime (CLR), which in turn interacts with the operating system and the hardware This way programs you write using C# can run on different operating systems and hardware platforms as long as it has the correct version of the .Net installed on it

18 Common Language Runtime
Execution Engine of .Net Manages the execution of programs and provides core services: Code compilation Memory allocation Thread management Garbage collection

19 Class Libraries Designed to integrate with the common language runtime
This library gives the program access to runtime environment The class library consists of lots of prewritten code that all the applications created in VC# .Net and Visual Studio .Net will use The code in Visual C # for all the elements like forms, and controls actually comes from the class library

20 Namespaces Within the .NET Framework, related classes are grouped into Namespaces You need to insert a “using AppropriateNamespace” in your program After that you can refer to methods and attributes of classes contained therein

21 To Get .Net Namespace Documentation
Visit:

22 How Do You Write and Run a Program?
Use visual studio to create a project. The project file will have the extension csproj. The project stores all related files, including the source file you write. Every project has a solution file with the extension sln. You would be opening this file when you want to return to your program you were writing. This will open all associated files. The associated files may be contained in a subdirectory. After writing the source code, go to build and build your solution, which creates the intermediate code. Go to debug and start without debugging. The program run will finish and give you a prompt to press any key to continue. Start with debugging, it will complete the run and return to you to the IDE. If your IDE does offer “without debugging”, add a console.readkey() statement.

23 Options for a New Project
Console application Windows forms application

24 Hello Program using System; //using System.Collections.Generic;
//using System.Linq; //using System.Text; namespace sayHello { class sayHello static void Main(string[] args) Console.WriteLine("Hello!"); Console.WriteLine("Welcome to Dr. Lian's C# Class!"); Console.ReadLine(); }

25 Using the Form Designer
You can size the form by holding the handles in the corners or the middle Controls and other items are added to the form using the toolbox. If control or item has properties that can be set To write the code for an event, you can click on the view code button above the solution explorer or by simply clicking on a button or anything else on the form Files with code you write will have extension .cs. Files ending with designer.cs are code files generated by visual studio

26 Naming Controls and Boxes
Use a convention you will remember You can start all button names with btn An accept button will be named btnAccept An exit button will be named btnExit All text boxes will start with txt Sales amount will be named txtSalesAmount All labels with start with lbl lblEnterName It is up to you to choose naming conventions you will recognize

27 Your First Assignment Assignment #1
The purpose of this assignment is to practice reading and writing to console using C#. It is a simple assignment. Use the following program run to design and write your program. Please submit Program listing and a screen capture of the program run. Follow the textbook examples to add comments as documentation.

28 Assignment Submission
Make sure to include your name, assignment number, date due and date completed on each assignment you submit Assignment should be submitted in a manila folder with your name and assignment number appearing on the tab Submit your assignments to the Blackboard

29 Exercises Give a brief explanation of the .NET framework
What is the Common Language Runtime? How do you place “Total Square Feet: 1238” in a text box? Assume that 1238 in an integer stored in a variable called sqFt.


Download ppt "CSCI 3328 Object Oriented Programming in C# Chapter 1: Introduction to C# UTPA – Fall 2012 This set of slides is revised from lecture slides of Prof."

Similar presentations


Ads by Google