The First C# Program Elements of a C# Program. Exploring the First C# Program // Namespace Declaration using System; namespace HolaMundo { /// /// Summary.

Slides:



Advertisements
Similar presentations
C# Language Report By Trevor Adams. Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect.
Advertisements

Classes  All code in a Java program is part of a class  A class has two purposes  Provide functions to do work for the programmer  Represent data.
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
PACKAGES. PACKAGES IN JAVA A package is a collection of related classes and interfaces in Java Packages help in logical grouping of classes and interfaces.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Introduction to the C# Programming Language for the VB Programmer.
Advanced Object-Oriented Programming Features
Trey Mack James Moore Osa Osar-Emokpae
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program C# Programming: From Problem Analysis to Program Design 2 nd Edition.
C# Programming: From Problem Analysis to Program Design1 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
Introduction to Computing and Programming
Chapter Objectives You should be able to describe: Object-Based Programming Classes Constructors Examples Common Programming Errors.
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program.
GTECH 731 Lab Session 2 Lab 1 Review, Lab 2 Intro 9/6/10 Lab 1 Review Lab 2 Overview.
Introduction to Methods
C# Tutorial From C++ to C#. Some useful links Msdn C# us/library/kx37x362.aspxhttp://msdn.microsoft.com/en- us/library/kx37x362.aspx.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Chapter 3 Getting Started with C++
Introduction to Classes SWE 344 Internet Protocols & Client Server Programming.
BIM313 – Advanced Programming Techniques Object-Oriented Programming 1.
C# B 1 CSC 298 Writing a C# application. C# B 2 A first C# application // Display Hello, world on the screen public class HelloWorld { public static void.
Introduction to Object-Oriented Programming
CSC 142 B 1 CSC 142 Java objects: a first view [Reading: chapters 1 & 2]
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Introduction to C# C# is - elegant, type-safe, object oriented language enabling to build applications that run on the.NET framework - types of applications.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
C# D1 CSC 298 Elements of C# code (part 2). C# D2 Writing a class (or a struct)  Similarly to Java or C++  Fields: to hold the class data  Methods:
Introduction to Building Windows 8.1 & Windows Phone Applications.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
Beginning C++ Through Game Programming, Second Edition
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
Classes and Objects in Java
1 Introduction to C# Programming Console applications No visual components Only text output Two types MS-DOS prompt - Used in Windows 95/98/ME Command.
Introduction to C#. Why C#? Develop on the Following Platforms ASP.NET Native Windows Windows 8 / 8.1 Windows Phone WPF Android (Xamarin) iOS (Xamarin)
C# Programming: From Problem Analysis to Program Design1 10 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
Writing Static Methods Up until now, we have been USING (calling) static methods that other people have written. Now, we will start CREATING our own static.
Structures and Classes Version 1.0. Topics Structures Classes Writing Structures & Classes Member Functions Class Diagrams.
Hello Computer Science!. Below is an example of a Hello World program in JAVA. While it is only three lines of code, there are many things that are happening.
2 Objectives You should be able to describe: Object-Based Programming Classes Constructors Examples Common Programming Errors.
24-Dec-15 Class Structure. 2 Classes A class describes a set of objects The objects are called instances of the class A class describes: Fields (instance.
Introduction to Object-Oriented Programming Lesson 2.
By Mr. Muhammad Pervez Akhtar
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 – Introduction to C# Programming Outline 3.1 Introduction 3.2 Simple Program: Printing a Line.
Agenda Comments Identifiers Keywords Syntax and Symentics Indentation Variables Datatype Operator.
Session 1 C# Basics.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Programming in java Packages Access Protection Importing packages Java program structure Interfaces Why interface Defining interface Accessing impln thru.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Packages. The main feature of OOP is its ability to support the reuse of code: –Extending the classes –Extending interfaces The features in basic form.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
Chapter 5 Methods 1. Motivations Method : groups statements that perform a function.  Level of abstraction (black box)  Code Reuse – no need to reinvent.
By : Robert Apeldorn. What is OOP?  Object-oriented programming is a programming paradigm that uses “objects” to design applications and computer programs.
1 Introduction to Object Oriented Programming Chapter 10.
Classes - Intermediate
CSC 110 – Intro to Computing - Programming
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
CSCE Introduction to Program Design and Concepts J. Michael Moore Spring 2015 Set 6: Miscellaneous 1 Based on slides created by Bjarne Stroustrup.
Learning Plan 6 Java Programming Intro to Object Oriented Programming.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
INTRODUCTION BEGINNING C#. C# AND THE.NET RUNTIME AND LIBRARIES The C# compiler compiles and convert C# programs. NET Common Language Runtime (CLR) executes.
C# Programming: From Problem Analysis to Program Design
Chapter 3 – Introduction to C# Programming
Namespaces How Shall I Name Thee?.
class PrintOnetoTen { public static void main(String args[]) {
How to organize and document your classes
Classes, Objects and Methods
Consider the following code:
Presentation transcript:

The First C# Program Elements of a C# Program

Exploring the First C# Program // Namespace Declaration using System; namespace HolaMundo { /// /// Summary description for Class1. /// // Program start class class Class1 { /* Main begins program execution The main entry point for the application. */ static void Main(string[] args) { Console.WriteLine("Hola mundo"); } } }

Comentarios Los comentarios sirven dos funciones : Hace que el código sea más fácil de leer Internamente documentan que hace los enunciados del programa

Diferentes tipos de comentarios Comentarios de una solo linea Comentarios de multiples linea Comentarios estilo xml ( extensible markup language)

Using directives and namespaces Namespace: A namespace can be seen as a container for some classes in much the same way that a folder on your file system contains files. By putting the classes into namespaces we can group related classes together. If two classes have the same name, by placing them in different namespaces, we avoid the risk of name collisions.

Namespaces It is recommended that you define all your classes in a namespace. Every single class in the.net Framework lives inside a namespace..net provides the significant benefit of making available more than 2,000 classes that make up what is called the Framework Class Library(FCL). A class contains code that can be reused, which makes programming easier and faster because you don’t have to reinvent the wheel.

namespaces The Console class lives inside the System namespace. This means that its fully qualified name is actually System.Console. The using directive allows making the names of the classes inside the namespace visible outside the namespace in their shorthand form. Ver ejemple con la clase Console

Forma general de un programa using System; namespace MyNamespace1 { class MyClass1 { } struct MyStruct { } interface IMyInterface { } delegate int MyDelegate(); enum MyEnum { } namespace MyNamespace2 { } class MyClass2 { public static void Main(string[] args) { } } }

Namespaces C# Language programs can consist of one or more files. Each file can contain one or more namespaces. A namespace can contain types such as classes, structs, interfaces, enumerations, and delegates, in addition to other namespaces.

Classes C# is an object-oriented language, everything in C# is designed around a class C# doesn’t allow anything to be defined outside of a class. All methods must be defined inside a class.

Classes Programs written using C# can use these predefined.NET classes or create their own classes. It is tradition to name the file conaining the class the same name as the class neme, except the file name will have a.cs extention.

Classes Console is a built-in class that contains the methods for displaying messages on the screen and getting input from the keyboard. Within the curly braces, you define the class members. A class member is generally either a member method, which performs some behavior of the class, or a data member, which contais a value associated with the state of the class.

Main method The Main method is special, it designates the program’s entry point. It must be a static method. This is where the program begins execution

methods A collection of one or more statement combined to perform an acton. Methods are similar to functions in C++. Signature and heading

Method body- Statements Console.WriteLine(“Hola Mundo”); Console.Write(“ “); Console.Write(“What goes\nup\nmust come\tdown”);