Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Programming In C#

A brief introduction to programming with the C# language
by

Sergio Rossi

on 9 October 2012

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Programming In C#

C# Programming in A Prezi By Sergio Rossi So What Is C#? C# Is a programming language. It uses the .NET framework.
It's a "multi-paradigm" programming language.
It uses "object oriented" programming.
It's a succesor of the popular "C++" language How Does A C# Program Work? A program is written in C# using a variety of structures, the most common of which are: Variables

Classes Methods

Namespaces Variables A Variable is a memory structure used for storing different types of data. Int Used for storing whole numbers up to
2147483647 (and the negative) int num=145;
int awnser=5+4*2; Float Used for storing decimal numbers from
1.5 x 10 to 3.4 x 10 float price=12.75;
float quotient=7.00/3.00; -45 38 Bool Stores a single value of
either "true" or "false" bool isActive=true;
bool greater=35>22; Char Can store a single Unicode character inside a pair of single quotes. char grade='A';
char awnser='\n'; String Stores a line of text containing a series of characters enclosed in double quotes. string welcome="Hello!";
string greeting
="Mr. "+name; Technically not a variable! Math Operators These symbols can be used to compute numbers and preform math functions. + :Addition
- :Subraction
* :Multiplication
/ :Soft Divison
% :Modulation The Math class can be used for even more functions. Math.Pow(x,y): Returns X to the power of Y
Math.Sqrt(X): Returns the square root of X
Math.PI: Returns Pi to the 20th place. Escape Sequences Some symbols like tab, double quotes, and apostrophe have different uses in strings and chars, so in order to use them, one must use escape sequences. \' :Single Quote/Apostrophe
\" :Double Quote
\\ :Backslash
\n :New Line/Return
\t :Tab
\uxxxx :Unicode Characer (where xxxx is the four digit character code) Logic Operators These symbols are used to check logical statements and conditions. They return either true or false. && :AND, true if both are true, false otherwise.
|| :OR, true if either are true, false otherwise.
! :NOT, inverts outcome Equality symbols can also be used to compare other data types. == :Equal to
!= :Not Equal to
> :Greater than
< :Less than
>= :Greater than or Equal to
<= :Less than or Equal to Methods A Method is a block of code that can be called upon to preform a function, return a value, or test a condition. Parts of a Method public static int DoMath(int number); Visibility Modifier
This determines what parts of the program can use the method. Static Modifier
When a method is "static", only one instance of it can ever be running at a time, so it must be called by the class and not the object. Return Type
This indicates what type of data the method returns. If the method does not return anything, the return type is "void" Identifier
This is the name of the method itself. It can be any word that not already being used int he program or by the language. Parameters
These are variables used in the program that can be specified when the method is called. The word before each parameter is the type of data it is. Parenthesis
Every method must have a pair of parenthesis after it, even if it has no parameters. This tells the computer that the identifier is calling a method. public int DoMath(int number)
{
int product;
product=number*15;
if(product==0)
{
return 0;
}
else
{
int divisor;
while(divisor>52)
{
divisor=365/product;
}
return divisor;
}
} Parts of a Method (Cont.) If & Else Statements An If statement checks whether a certain condition in true or false. If it is true, it executes the code inside it's brackets, but if it is false, it executes the code inside the Else block instead. While Statements A While statement is a type of loop. It acts like an If statement initially, but once it reaches the end of it's brackets, it checks it's condition again. If the condition is still true, it starts executing the code block all over again. It continually loops the code segment until the condition is eventually false (or the computer runs out of memory!) Return Statements When a Return statement is run, the method immediately ends and return the following value to the code that called it. The returned data must be of the same data type specified in the method header or an error will occur. Even in a void method, and empty return method can be called to simply end the method prematurely. Classes A Class is a group of variables, methods, and other constructs that determine the way Objects act. Objects are made using Classes as blueprints. Book Class string author;
string publisher;
int iSBN; Fiction
Book Class string author;
string publisher;
int iSBN;
string fictionType; string author;
string publisher;
int iSBN;
string historyType; History
Book Class Object mathTextbook author="Berchie Holliday";
publisher="Glencoe";
iSBN=9780028341750; Object childhoodsEnd author="Arthur C. Clarke";
publisher="Ballantine Books";
iSBN=0345347951;
fictionType="Science Fiction"; Object itsBeenAGoodLife author="Isaac Asimov";
publisher="Prometheus Books";
iSBN=1573929689;
historyType="Autobiography"; Is-A Relationship
An Object and it's Class have what is called an "Is-A" relationship. A class is the idea of an object, while an object is an example of that idea. Therefore, one could say a Text Book "is a" Book. Inheritance
Classes can be made using another class as a "Parent". They become that class' "Child", and automatically share all the variables and methods contained in the parent class. Bird Class implements Flying
void Fly();
void Glide(); Airplane Class implements Flying
void Fly();
bool IsCrusing(); Bee Class implements Flying
void Fly();
void Sting();
int GetPollen(); Interface Flying void Fly(); Helicopter Class implements Flying
void Fly();
void Hover(); Implementing Interfaces
Classes can also implement structures called Interfaces when beign created. An interface is a guideline for methods, but does not actually provide a method for the class. It can be used to group classes that all do similar things. Namespaces A Namespace is a collection of classes with methods and variables. It is the essence of a program written in C#. Class Phone string[] callHistory;
int phoneNumber;
int[] contacts; Class Camera Photos[] pictures;
Video[] movies; Class System int batteryLevel;
float memorySpace;
int passcode;
float time; Class IPod Songs[] music;
string[] albums;
string[] artists; Class Safari string[] history;
Webpage[] tabs;
string homeSite; Class Texting string[][] messages;
string[] contacts; Namespace IPhone Prezi.WriteLine("The End");
break;
Full transcript