Submit Search
Upload
C# Basics
•
6 likes
•
481,545 views
Sunil OS
Follow
Basics of C# programming
Read less
Read more
Technology
Report
Share
Report
Share
1 of 43
Recommended
C# in depth
C# in depth
Arnon Axelrod
Introduction To C#
Introduction To C#
SAMIR BHOGAYTA
C# - Part 1
C# - Part 1
Md. Mahedee Hasan
C# basics
C# basics
Dinesh kumar
CSharp Presentation
CSharp Presentation
Vishwa Mohan
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Hawkman Academy
Introduction to c#
Introduction to c#
OpenSource Technologies Pvt. Ltd.
Object-oriented Programming-with C#
Object-oriented Programming-with C#
Doncho Minkov
Recommended
C# in depth
C# in depth
Arnon Axelrod
Introduction To C#
Introduction To C#
SAMIR BHOGAYTA
C# - Part 1
C# - Part 1
Md. Mahedee Hasan
C# basics
C# basics
Dinesh kumar
CSharp Presentation
CSharp Presentation
Vishwa Mohan
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
Hawkman Academy
Introduction to c#
Introduction to c#
OpenSource Technologies Pvt. Ltd.
Object-oriented Programming-with C#
Object-oriented Programming-with C#
Doncho Minkov
C# Exceptions Handling
C# Exceptions Handling
sharqiyem
C# Tutorial
C# Tutorial
Jm Ramos
Php basics
Php basics
Jamshid Hashimi
Presentation on C++ Programming Language
Presentation on C++ Programming Language
satvirsandhu9
Classes objects in java
Classes objects in java
Madishetty Prathibha
Programming in c#
Programming in c#
Shehrevar Davierwala
C#.NET
C#.NET
gurchet
OOP java
OOP java
xball977
Java Data Types
Java Data Types
Spotle.ai
Introduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
Python programming : Control statements
Python programming : Control statements
Emertxe Information Technologies Pvt Ltd
.NET and C# Introduction
.NET and C# Introduction
Siraj Memon
C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#
Dr.Neeraj Kumar Pandey
for loop in java
for loop in java
Majid Ali
c# usage,applications and advantages
c# usage,applications and advantages
mohamed drahem
Introduction to c#
Introduction to c#
Ravi Jakashania
JAVA OOP
JAVA OOP
Sunil OS
C# classes objects
C# classes objects
Dr.Neeraj Kumar Pandey
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
Edureka!
Web api
Web api
Sudhakar Sharma
C# Variables and Operators
C# Variables and Operators
Sunil OS
Unit3 overview of_c_programming
Unit3 overview of_c_programming
Capuchino HuiNing
More Related Content
What's hot
C# Exceptions Handling
C# Exceptions Handling
sharqiyem
C# Tutorial
C# Tutorial
Jm Ramos
Php basics
Php basics
Jamshid Hashimi
Presentation on C++ Programming Language
Presentation on C++ Programming Language
satvirsandhu9
Classes objects in java
Classes objects in java
Madishetty Prathibha
Programming in c#
Programming in c#
Shehrevar Davierwala
C#.NET
C#.NET
gurchet
OOP java
OOP java
xball977
Java Data Types
Java Data Types
Spotle.ai
Introduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
Python programming : Control statements
Python programming : Control statements
Emertxe Information Technologies Pvt Ltd
.NET and C# Introduction
.NET and C# Introduction
Siraj Memon
C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#
Dr.Neeraj Kumar Pandey
for loop in java
for loop in java
Majid Ali
c# usage,applications and advantages
c# usage,applications and advantages
mohamed drahem
Introduction to c#
Introduction to c#
Ravi Jakashania
JAVA OOP
JAVA OOP
Sunil OS
C# classes objects
C# classes objects
Dr.Neeraj Kumar Pandey
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
Edureka!
Web api
Web api
Sudhakar Sharma
What's hot
(20)
C# Exceptions Handling
C# Exceptions Handling
C# Tutorial
C# Tutorial
Php basics
Php basics
Presentation on C++ Programming Language
Presentation on C++ Programming Language
Classes objects in java
Classes objects in java
Programming in c#
Programming in c#
C#.NET
C#.NET
OOP java
OOP java
Java Data Types
Java Data Types
Introduction to ASP.NET
Introduction to ASP.NET
Python programming : Control statements
Python programming : Control statements
.NET and C# Introduction
.NET and C# Introduction
C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#
for loop in java
for loop in java
c# usage,applications and advantages
c# usage,applications and advantages
Introduction to c#
Introduction to c#
JAVA OOP
JAVA OOP
C# classes objects
C# classes objects
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
Web api
Web api
Similar to C# Basics
C# Variables and Operators
C# Variables and Operators
Sunil OS
Unit3 overview of_c_programming
Unit3 overview of_c_programming
Capuchino HuiNing
Srgoc dotnet
Srgoc dotnet
Gaurav Singh
Retour sur la Microsoft //Build 2018
Retour sur la Microsoft //Build 2018
Timothé Larivière
C++primer
C++primer
leonlongli
C++ Interface Versioning
C++ Interface Versioning
Skills Matter
C++ language
C++ language
Elizabeth Pisarek
Initial Java Core Concept
Initial Java Core Concept
Rays Technologies
Cross Platform App Development with C++
Cross Platform App Development with C++
Joan Puig Sanz
Oop Presentation
Oop Presentation
Ganesh Samarthyam
Computer Project For Class XII Topic - The Snake Game
Computer Project For Class XII Topic - The Snake Game
Pritam Samanta
CSE215_Module_02_Elementary_Programming.ppt
CSE215_Module_02_Elementary_Programming.ppt
RashedurRahman18
Programming in C Presentation upto FILE
Programming in C Presentation upto FILE
Dipta Saha
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
Eelco Visser
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
.NET Conf UY
Roslyn: el futuro de C#
Roslyn: el futuro de C#
Rodolfo Finochietti
srgoc
srgoc
Gaurav Singh
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
YashwanthCse
Eclipse Training - Main eclipse ecosystem classes
Eclipse Training - Main eclipse ecosystem classes
Luca D'Onofrio
System programmin practical file
System programmin practical file
Ankit Dixit
Similar to C# Basics
(20)
C# Variables and Operators
C# Variables and Operators
Unit3 overview of_c_programming
Unit3 overview of_c_programming
Srgoc dotnet
Srgoc dotnet
Retour sur la Microsoft //Build 2018
Retour sur la Microsoft //Build 2018
C++primer
C++primer
C++ Interface Versioning
C++ Interface Versioning
C++ language
C++ language
Initial Java Core Concept
Initial Java Core Concept
Cross Platform App Development with C++
Cross Platform App Development with C++
Oop Presentation
Oop Presentation
Computer Project For Class XII Topic - The Snake Game
Computer Project For Class XII Topic - The Snake Game
CSE215_Module_02_Elementary_Programming.ppt
CSE215_Module_02_Elementary_Programming.ppt
Programming in C Presentation upto FILE
Programming in C Presentation upto FILE
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
Roslyn: el futuro de C# y VB.NET by Rodolfo Finochietti
Roslyn: el futuro de C#
Roslyn: el futuro de C#
srgoc
srgoc
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
Eclipse Training - Main eclipse ecosystem classes
Eclipse Training - Main eclipse ecosystem classes
System programmin practical file
System programmin practical file
More from Sunil OS
Threads V4
Threads V4
Sunil OS
Java IO Streams V4
Java IO Streams V4
Sunil OS
OOP V3.1
OOP V3.1
Sunil OS
Java Basics V3
Java Basics V3
Sunil OS
DJango
DJango
Sunil OS
PDBC
PDBC
Sunil OS
OOP v3
OOP v3
Sunil OS
Threads v3
Threads v3
Sunil OS
Exception Handling v3
Exception Handling v3
Sunil OS
Collection v3
Collection v3
Sunil OS
Java 8 - CJ
Java 8 - CJ
Sunil OS
Machine learning ( Part 3 )
Machine learning ( Part 3 )
Sunil OS
Machine learning ( Part 2 )
Machine learning ( Part 2 )
Sunil OS
Machine learning ( Part 1 )
Machine learning ( Part 1 )
Sunil OS
Python Pandas
Python Pandas
Sunil OS
Python part2 v1
Python part2 v1
Sunil OS
Angular 8
Angular 8
Sunil OS
Python Part 1
Python Part 1
Sunil OS
Rays Technologies
Rays Technologies
Sunil OS
Hibernate
Hibernate
Sunil OS
More from Sunil OS
(20)
Threads V4
Threads V4
Java IO Streams V4
Java IO Streams V4
OOP V3.1
OOP V3.1
Java Basics V3
Java Basics V3
DJango
DJango
PDBC
PDBC
OOP v3
OOP v3
Threads v3
Threads v3
Exception Handling v3
Exception Handling v3
Collection v3
Collection v3
Java 8 - CJ
Java 8 - CJ
Machine learning ( Part 3 )
Machine learning ( Part 3 )
Machine learning ( Part 2 )
Machine learning ( Part 2 )
Machine learning ( Part 1 )
Machine learning ( Part 1 )
Python Pandas
Python Pandas
Python part2 v1
Python part2 v1
Angular 8
Angular 8
Python Part 1
Python Part 1
Rays Technologies
Rays Technologies
Hibernate
Hibernate
Recently uploaded
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Michael W. Hawkins
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Principled Technologies
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Anna Loughnan Colquhoun
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Neo4j
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
The Digital Insurer
🐬 The future of MySQL is Postgres 🐘
🐬 The future of MySQL is Postgres 🐘
RTylerCroy
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
wesley chun
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Delhi Call girls
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
HampshireHUG
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Drew Madelung
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
Puma Security, LLC
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Martijn de Jong
Slack Application Development 101 Slides
Slack Application Development 101 Slides
praypatel2
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Delhi Call girls
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Enterprise Knowledge
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Delhi Call girls
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Delhi Call girls
Recently uploaded
(20)
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
🐬 The future of MySQL is Postgres 🐘
🐬 The future of MySQL is Postgres 🐘
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Slack Application Development 101 Slides
Slack Application Development 101 Slides
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
C# Basics
1.
© Rays Technologies
1 C# BASICS www.sunilos.com www.raystec.com 10/14/16
2.
10/14/16 © Rays
Technologies 2 C# Object Oriented Programming Language Basic unit of C# is Object An Object is an instances of Class Class defines structure/skeleton of an Object The basic building blocks of C# is a Class so a C# program is nothing but a class
3.
10/14/16 © Rays
Technologies 3 C# Class contains methods and variables Variables contains values Methods perform operations A Class should have default method ‘Main’ that is entry point of an application
4.
10/14/16 © Rays
Technologies 4 Program Procedural Language int i = 5 //global variable void main(){ .. a(); } void a(int k){ int j = 0; //local variable .. }
5.
10/14/16 © Rays
Technologies 5 Procedural Language Library Library Program 1 Program 2 Program 3 Program 4
6.
10/14/16 © Rays
Technologies 6 Class C# Language int i = 5 //global variable void main(){ .. a(); } void a(int k){ int j = 0; //local variable .. }
7.
10/14/16 © Rays
Technologies 7 C # Library Namespace Class 1 Class 2 Class 3 Class 4
8.
10/14/16 © Rays
Technologies 8 C# Application ApplicationApplication Napspace 1 Namespace 2 Namespace 3 Namspace 4
9.
10/14/16 © Rays
Technologies 9 C# Program is a Class public class HelloCSharp{ ……. } A class may contain multiple variables and methods A Class should have default ‘Main’ method that is an entry point for an application
10.
10/14/16 © Rays
Technologies 10 My First Program - HelloCSharp using System; public class HelloCSharp { o public static void Main() { o String name = “Vijay”; o Console.WriteLine(“Hello” + name); o } } using, public, class, static, and void are keywords Keywords are always written in small letters
11.
10/14/16 © Rays
Technologies 11 Compile & Run Compile o csc HelloCSharp.cs o It will generate HelloCSharp.exe Run o HelloCSharp
12.
10/14/16 © Rays
Technologies 12 Keywords class – is used to define a class public – Access modifier shows accessibility of a class or variable or method to other C# classes. There are 3 access modifiers public, protected and private static – Memory for the static variables are assigned only once in their life. Non-static variables are called instance variables void – is a NULL return type of Main method
13.
10/14/16 © Rays
Technologies 13 Commands Console.write()/Console.WriteLine() command is used to write text at standard output device String is a data type Two strings are concated by + operator o “Hello” + name
14.
10/14/16 © Rays
Technologies 14 Main method The Main method is sometimes called the application's entry point. Can be declared as public static void Main(){} OR public static void Main(string args[]){} OR public static int Main() {… return errorCode} OR public static int Main(string args[]) {… return errorCode}
15.
© Rays Technologies While 10/14/16
15
16.
10/14/16 © Rays
Technologies 16 Print Hello C# 5 times - while using System; public class HelloWhile { public static void Main(String[] args) { o boolean isAlive = true; o int round = 0; o while (isAlive) { o Console.WriteLine(“Basanti will dance"); o round++; o If(round>500 ) isAlive =false; o } }}
17.
© Rays Technologies For
10 Rs 5 shots How Much? Okey!! 10/14/16 17
18.
© Rays Technologies For
Loop using System; public class HelloFor { public static void Main() { ofor (int hits = 1; hits <= 5; hits++) { Console.WriteLine( “Shot Balloon"); o} o} } 10/14/16 18
19.
10/14/16 © Rays
Technologies 19 Print Hello C# 5 times – do-while using System; public class HelloDoWhile { public static void Main() { o int i = 0; o do { Console.WriteLine ( i+ “ Hello C#"); i++; o } while (i < 5); } }
20.
10/14/16 © Rays
Technologies 20 Add.java using System; public class Add { public static void Main(String[] args) { oint a = 5; oint b = 10; oint sum = a + b; oConsole.WriteLine ("Sum is " + sum); } }
21.
10/14/16 © Rays
Technologies 21 switch public static void Main() { String country = “India”; switch(country) { case “India” : o Console.WriteLine(“Language is Hindi"); o break; case “US” : case “England” : o Console.WriteLine(“Language is English”); o break; default : o Console.WriteLine(“Don’t know language {0}”, country); o break; }//switch }//method
22.
10/14/16 © Rays
Technologies 22 Value Types int long sbyte short float double 1 2 4 8 4 8 -128, +127 -9.223E18, +9.223E18 -32768, +32767 -2147483648, +2147483647 +3.4 E+38 +1.7 E+308 TypeType Size ByteSize Byte RangeRange char 2 0, 65535 (Unicode) bool 1 true, false 0 0 0 0 0 0 0 false DefaultDefault
23.
10/14/16 © Rays
Technologies 23 Value Types uint ulong byte ushort decimal 1 2 4 8 16 0, 255 0 .. 264-1 0, 65535 0,4294967295 ± 1E-28 .. ±7.9E28 TypeType Size ByteSize Byte RangeRange 0 0 0 0 0 DefaultDefault
24.
10/14/16 © Rays
Technologies 24 Other Data Types Reference types (composite) o objects o arrays strings is a reference data type
25.
10/14/16 © Rays
Technologies 25 System.String class public static void Main() { String name = "Vijay Dinanth Chouhan"; Console.WriteLine(" String Length- " + name.Length); Console.WriteLine(" 7 ths caharcter is- " + name[6]); Console.WriteLine(" Dina index is- " + name.IndexOf("Dina")); Console.WriteLine(" First i Position- " + name.IndexOf("i")); Console.WriteLine(" Last i Position- " + name.LastIndexOf("i")); Console.WriteLine(" a is replaced by b- " + name.Replace("a", "b")); Console.WriteLine(" Chota vijay- " + name.ToLower()); Console.WriteLine(" Bada vijay- " + name.ToUpper()); Console.WriteLine(" Starts With Vijay- " + name.StartsWith("Vijay")); Console.WriteLine(" Ends with han- " + name.EndsWith("han")); Console.WriteLine(" Substring- " + name.Substring(6)); }
26.
10/14/16 © Rays
Technologies 26 System.Math class public static void main(String[] args) { Console.WriteLine("Math functions"); Console.WriteLine(" Max 2,5 - " + Math.Max(2,5)); Console.WriteLine(" Min 2,5 - " + Math.Min(2,5)); Console.WriteLine(" Absolute 3.7 - " + Math.Abs(3.7)); Console.WriteLine(" Exp 10 - " + Math.Exp(10)); Console.WriteLine(" Square Root- " + Math.Sqrt(4)); }
27.
10/14/16 © Rays
Technologies 27 Static vs Instance String name = “Vijay”; String surname = “Chohan” C.WL(name.Length); C.WL(surname.Length); String.Length C.WL(Math.Max(2,5)); C.WL(Math.Max(5,10));
28.
10/14/16 © Rays
Technologies 28 Hello <Name> public class HelloName { public static void Main(String[] args) { Console.WriteLine("Hello " + args[0]); } }
29.
10/14/16 © Rays
Technologies 29 Hello Name – if <condition> public class HelloName{ public static void Main(String[] args) { o if (args.Length == 1) { Console.WriteLine("Hello " + args[0]); o } else { Console.WriteLine("Usage : HelloName <name>"); o } } }
30.
10/14/16 © Rays
Technologies 30 Hello All public class HelloAll { public static void Main(String[] args) { o for (int i = 0; i < args.Length; i++) { Console.WriteLine(i + " = Hello " + args[i]); o } } }
31.
10/14/16 © Rays
Technologies 31 Hello All - define Method public static void Main(String[] args) { o PrintAll(args); }// main public static void PrintAll(String[] args) { o int size = args.Length; o for (int i = 0; i < size; i++) { Console.WriteLine((i + 1) + " = Hello " + args[i]); o } }//myMethod
32.
10/14/16 © Rays
Technologies 32 Add.java public class Add { public static void Main(String[] args) { o int a = Integer32.Parse(args[0]); o int b = Integer32.Parse (args[1]); o int sum = a + b; o Console.WriteLine("Sum is " + sum); } }
33.
10/14/16 © Rays
Technologies 33 Division public class Division { public static void Main(String[] args) { o int a = Integer32.Parse (args[0]); o int b = Integer32.Parse (args[1]); o double div = a/b; o Console.WriteLine("Division is " + div); } }
34.
10/14/16 © Rays
Technologies 34 Return a Value public class Division3 { public static void Main(String[] args) { o int a = Integer.Parse (args[0]); o int b = Integer.Parse (args[1]); o double div = getDivision(a, b); o Console.WriteLine("Division is " + div); } public static double getDivision(int a, int b) { o double div = a / b; o return div; } }
35.
10/14/16 © Rays
Technologies 35 10 One Dimension Array 20 [0] 18 .. 10 8 6 4 2 [1] [8] [9] [2] [3] [4] [n] Length int[] table = new int[10]; int a = table[4]; int a = table[2]; int size = table.Length
36.
10/14/16 © Rays
Technologies 36 10 Initialize an Array 20 [0] 18 .. 10 8 6 4 2 [1] [8] [9] [2] [3] [4] [n] Length int[] table = new int[10]; table[0] =2; table[1] =4; …. Or int[] table = {2,4,6,8,10,12,14,16,18, 20};
37.
10/14/16 © Rays
Technologies 37 Other Data Type Arrays char[] chList = new char[5]; chList[0] = ‘A’…. Or char[] chList = {‘A’,’B’,’C’,’D’,’E’} String[] strList = new String[5]; strList[0] = “A” strList[1] = “Bee” Console.WriteLine(strList[0]); …. Or String[] strList = {“A”,”Bee”,”Cee”,”Dee”,”E”}
38.
10/14/16 © Rays
Technologies 3810length 2D Array [0] 20 18 .. 10 8 6 4 2 [1] [8] [9] [2] [3] [4] [n] 30 27 .. 15 12 9 6 3 40 36 .. 20 16 12 8 4 90 81 .. 45 36 27 18 9 100 90 .. 50 40 30 20 10 … [0] [1] [2] [7] [8] 9 9 .. 9 9 9 9 9
39.
10/14/16 © Rays
Technologies 39 int[][] table = new int[10][9]; table[1][5] = 5; int size = table.Length; int size = table[0].Length; int[][] rows = new int[10][]; rows[0] = new int[9]; rows[1] = new int[19]; rows[2] = new int[29]; int xyz = new int[10][9][2];
40.
10/14/16 © Rays
Technologies 40 Rectangular Array
41.
10/14/16 © Rays
Technologies 41 3D Array 20 [0] 18 .. 10 8 6 4 2 [1] [8] [9] [2] [3] [4] [n] 30 27 .. 15 12 9 6 3 40 36 .. 20 16 12 8 4 90 81 .. 45 36 27 18 9 100 90 .. 50 40 30 20 10 [0] [1] [2] [8] [9] 20 18 .. 10 8 6 4 2 30 27 .. 15 12 9 6 3 40 36 .. 20 16 12 8 4 20 18 .. 10 8 6 4 30 27 .. 15 12 9 6 20 18 .. 10 8 6 4 2 30 27 .. 15 12 9 6 3 40 36 .. 20 16 12 8 4 90 81 .. 45 36 27 18 9 100 90 .. 50 40 30 20 10 90 81 .. 45 36 27 18 9 100 90 .. 50 40 30 20 10 … [0] [1] [2]
42.
Disclaimer This is an
educational presentation to enhance the skill of computer science students. This presentation is available for free to computer science students. Some internet images from different URLs are used in this presentation to simplify technical examples and correlate examples with the real world. We are grateful to owners of these URLs and pictures. © Rays Technologies 4210/14/16
43.
Thank You! © Rays
Technologies 43 www.SunilOS.com 10/14/16