C# Language Basics Imran Rashid CTO at ManiWeber Technologies.

Slides:



Advertisements
Similar presentations
The Line Class Suppose you are involved in the development of a large mathematical application, and this application needs an object to represent a Line.
Advertisements

1 C++ Syntax and Semantics The Development Process.
Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
1 Objects, Classes, and Packages “Static” Classes Introduction to Classes Object Variables and Object References Instantiating Objects Using Methods in.
GUIs Part 4 CS221 – 4/17/09. Professional Assignments Assignment #2 – Download and install Visual Studio 2008 Professional Trial Software –
A simple C++ program /* * This program prints the phrase "Hello world!" * on the screen */ #include using namespace std; int main () { cout
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
1.11 Introduction to OOP academy.zariba.com 1. Lecture Content 1.What is OOP and why use it? 2.Classes and objects 3.Static classes 4.Properties, fields.
110-D1 Variables, Constants and Calculations(1) Chapter 3: we are familiar with VB IDE (building a form…) to make our applications more powerful, we need.
Microsoft Visual Basic 2005: Reloaded Second Edition
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
1 C++ Syntax and Semantics, and the Program Development Process.
Chapter 2. C++ Program Structure C++ program is a collection of subprograms Subprograms in C++ are called FUNCTIONS Each function performs a specific.
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
CSC 142 Computer Science II Zhen Jiang West Chester University
C++ Programming Lecture 11 Functions – Part III By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
Chapter 2. Variable and Data type
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Chapter 3 Using Variables, Constants, Formatting Mrs. UlshaferSept
Bill Tucker Austin Community College COSC 1315
Introduction to Object-oriented Programming
More About Objects and Methods
Creating and Using Objects, Exceptions, Strings
Creating Your Own Classes
Topics Designing a Program Input, Processing, and Output
Working with Java.
Overview of c# Programming
Type Checking, and Scopes
Classes and OOP.
Variables A variable is a placeholder for a value. It is a named memory location where that value is stored. Use the name of a variable to access or update.
Basic Elements of C++.
More About Objects and Methods
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
ICS103 Programming in C Lecture 3: Introduction to C (2)
Microsoft Visual Basic 2005: Reloaded Second Edition
University of Central Florida COP 3330 Object Oriented Programming
Switch, Rounding Errors, Libraries
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
FUNDAMENTALS OF JAVA.
Instructor: Ioannis A. Vetsikas
Lecture Set 4 Data Types and Variables
Basic Elements of C++ Chapter 2.
Lecture 4 Using Classes Richard Gesick.
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Chapter 3 Introduction to Classes, Objects Methods and Strings
Advanced Programming Basics
Your First Java Application
Using Classes and Objects
CSE 3302 Programming Languages
More About Data Types & Functions
Chapter 1: Computer Systems
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
Programming games Classes and objects (used for Jigsaw, Bouncing stuff, other projects) Homework: Complete cannonball. Video or Audio. Your own project.
CSCI 3328 Object Oriented Programming in C# Chapter 6: Methods
Topics Designing a Program Input, Processing, and Output
String.
Web & Mobile App Directory Structure
Topics Designing a Program Input, Processing, and Output
CSE 3302 Programming Languages
Functions Imran Rashid CTO at ManiWeber Technologies.
Classes and Objects Imran Rashid CTO at ManiWeber Technologies.
Understanding Variables
Variables and Constants
Presentation transcript:

C# Language Basics Imran Rashid CTO at ManiWeber Technologies

Outline The Nature of C# A Class Definition The Base Class Library (BCL) Diagramming C# Classes Guidelines

The Nature of C#

The Nature of C# C# is an object-oriented language not procedural Does not supports global variables or functions Objects are defined in classes and structures Persistent data is stored in member fields Behaviors are defined in member methods Everything is part of a class or structure So in C# everything is an object Members are also called fields, attributes or properties Methods are also called functions, actions or behaviors Objects are also called instances

A Class Definition

A Class Definition

The Base Class Library (BCL)

The Base Class Library (BCL) Defined classes and for all frameworks File management, math, other common operations Example: Mathematical Operations Common math tasks are in System.Math System is the name of Namespace Math is the name of Class Most operations are static methods You can access a static member using the type name instead of a reference or a value e.g. Math.Round(double) using System.Math; double pi = Math.PI; // A field double rounded = Math.Round(pi, 2); // A method Console.WriteLine(rounded); // 3.14

Diagramming C# Classes

Diagramming C# Classes

Guidelines

Guidelines Who Decides? Naming Rules Enforced by Compiler Some naming rules are enforced by the complier Unforced guidelines are suggested by Microsoft Some controversy / disagreements do exists Solo developers get to decide for themselves Teams should agree on guidelines for their projects Naming Rules Enforced by Compiler Identifiers names can include alphanumeric characters Cannot include special characters other than underscore Must start with an alpha or underscore, not a number

Guidelines Case Sensitivity firstName FirstName FIRSTNAME An identifier is the name of a programming element What’s named: methods, variables, properties, and more Identifier in C# are case-sensitive; these are different firstName FirstName FIRSTNAME

Guidelines General Recommendations Variables, Fields, Parameters Choose easily readable identifiers names Always favor readability over simplicity or shortcuts No underscores, hyphens, other special characters No “Hungarian” notation: strFirstName, iAge Exception: naming visual objects in XAML Variables, Fields, Parameters Start with lower-case character Use camel-case to distinguish words int i = 0; double thePrice = 14.95; string firstName = “Gims”;

const int HomeRunRecord = 61; Guidelines All Others: Pascal Casing Initial upper-case character, camel-case for the rest Use camel-case only notation for variables and parameters Use Pascal casing for all other identifiers: Methods Constants Properties const int HomeRunRecord = 61;

Any ?