SlideShare uma empresa Scribd logo
1 de 20
Bhushan Mulmule
bhushan.mulmule@dotnetvideotutorial.com
www.dotnetvideotutorial.com
For video visit
www.dotnetvideotutorial.com
Agenda
 Single Dimensional Array
 Array Class
 Array of Reference Type
 Double Dimensional Array
 Jagged Array
 Structure
 Enum
www.dotnetvideotutorial.com
Array
 Data structure holding multiple values of same data-type
 Are reference type
 Derived from abstract base class Array
20 50 60
0 1 2
Arrays are zero
indexed
Last index is always
(size – 1)
5000
5000
marks
www.dotnetvideotutorial.com
Array Declarations
// Declare a single-dimensional array
int[] array1 = new int[5];
// Declare and set array element values, Size can be skipped
int[] array2 = new int[] { 1, 3, 5, 7, 9 };
// Alternative syntax. new keyword can be skipped
int[] array3 = { 1, 3, 5, 7, 9 };
// Declaration and instantiation on separate lines
int[] array4;
array4 = new int[5];
5000
5000
array1
0 1 2 3 4
www.dotnetvideotutorial.com
0 0 0
int[] marks = new int[3];
Console.WriteLine("Enter marks in three subjects:");
for (int i = 0; i < 3; i++)
marks[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Marks obtained:");
Console.WriteLine("Printed using for loop");
for (int i = 0; i < 3; i++)
Console.WriteLine(marks[i]);
Console.WriteLine("Printed using foreach loop");
foreach (int m in marks)
{
Console.WriteLine(m);
}
20 50 60
5000
5000
marks
The default value for elements
of numeric array is zero
0 1 2
Single Dimensional Array
www.dotnetvideotutorial.com
Array Class
 Base class for all arrays in the common language runtime.
 Provides methods for creating, manipulating, searching, and
sorting arrays
www.dotnetvideotutorial.com
Array Class
int[] numbers = { 78, 54, 76, 23, 87 };
//sorting
Array.Sort(numbers);
Console.WriteLine("sorted array: ");
for (int i = 0; i < numbers.Length; i++)
Console.WriteLine(numbers[i]);
//reversing
Array.Reverse(numbers);
...
//finding out index
int index = Array.IndexOf(numbers, 54);
Console.WriteLine("Index of 54: " + index);
www.dotnetvideotutorial.com
Array of Reference Types
static void Main(string[] args)
{
string[] computers = { "Titan", "Mira", "K computer" };
Console.WriteLine("Fastest Super Computers: n");
foreach (string n in computers)
{
Console.WriteLine(n);
}
}
2000 2200 1800
Titan
Mira
K Computer
2000 1800
2200
5000
5000
Computers
Note: Default value for elements
of reference array is null
int[,] marks = new int[3, 4];
for (int i = 0; i < 3; i++)
{
C.WL("Enter marks in 4 subjects of Student {0}", i + 1);
for (int j = 0; j < 4; j++)
{
marks[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
0 0 0 0
0 0 0 0
0 0 0 0
40 50 60 70
80 90 70 80
30 50 80 70
0
1
2
0 1 2 3
2D Array
www.dotnetvideotutorial.com
Console.WriteLine("---------------Score Board------------------");
for (int i = 0; i < 3; i++)
{
Console.Write("Student {0}:tt", i + 1);
for (int j = 0; j < 4; j++)
{
Console.Write(marks[i, j] + "t");
}
Console.WriteLine();
} 0 0 0 0
0 0 0 0
0 0 0 0
40 50 60 70
80 90 70 80
30 50 80 70
0
1
2
0 1 2 3
2D Array
www.dotnetvideotutorial.com
Jagged Array
 Array of Arrays: A jagged array is an array whose elements are
arrays.
 The elements of a jagged array can be of different dimensions
and sizes.
 Syntax:
type[][] identifier = new type[size][];
www.dotnetvideotutorial.com
Jagged Array
int[][] a = new int[3][];
a[0] = new int[2] { 32, 54 };
a[1] = new int[4] { 78, 96, 46, 38 };
a[2] = new int[3] { 54, 76, 23 };
2000
1800
2200
5000
5000
a
2000 2200 1800
32 54 54 76 23
78 96 46 38
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < a[i].Length; j++)
{
Console.Write(a[i][j] + "t");
}
Console.WriteLine();
}
2000
1800
2200
5000
5000
a
2000 2200 1800
32 54 54 76 23
78 96 46 38
Struct
 Keyword to create user defined datatype
 Typically used to encapsulate small groups of related variables
 A struct type is a value type
 Structs can implement an interface but can't inherit from
another struct or class.
NOTE: structs can contain constructors, constants, fields, methods, properties,
indexers, operators, events, and nested types, although if several such members are
required, consider making your type a class instead.
struct Point
{
public int x;
public int y;
}
class Program
{
static void Main(string[] args)
{
Point p1;
Console.WriteLine("Enter X and Y axis of point:");
p1.x = Convert.ToInt32(Console.ReadLine());
p1.y = Convert.ToInt32(Console.ReadLine());
C.WL("Coordinates of p1: x = {0}, y = {1}", p1.x, p1.y);
Console.ReadKey();
}
}
0 0
p1
x y
10 20
www.dotnetvideotutorial.com
Enum
enum Gender
{
Male,
Female,
Other
}
Gender g1 = Gender.Female;
1
g1
www.dotnetvideotutorial.com
Enums
 The enum keyword is used to declare an enumeration, a distinct
type consisting of a set of named constants called the
enumerator list.
 The default underlying type of the enumeration elements is int.
 By default, the first enumerator has the value 0, and the value of
each successive enumerator is increased by 1.
www.dotnetvideotutorial.com
enum Gender
{
Male = 10,
Female,
Other
}
class Program
{
static void Main(string[] args)
{
Gender g1 = Gender.Female;
C.WL("g1 represents {0}. But value stored is {1}", g1, (int)g1);
Gender g2 = Gender.Male;
C.WL("g2 represents {0}. But value stored is {1}", g2, (int)g2);
}
}
11
10
g1
g2
www.dotnetvideotutorial.com
Bhushan Mulmule
bhushan.mulmule@dotnetvideotutorial.com
www.dotnetvideotutorial.com

Mais conteúdo relacionado

Mais procurados

Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend classAbhishek Wadhwa
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple InheritanceBhavyaJain137
 
Control structures in c++
Control structures in c++Control structures in c++
Control structures in c++Nitin Jawla
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQLrehaniltifat
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Sanjit Shaw
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++HalaiHansaika
 
SQL Joinning.Database
SQL Joinning.DatabaseSQL Joinning.Database
SQL Joinning.DatabaseUmme habiba
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++Vraj Patel
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member FunctionsMOHIT AGARWAL
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member FunctionsMuhammad Hammad Waseem
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structureVardhil Patel
 

Mais procurados (20)

Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
 
Control structures in c++
Control structures in c++Control structures in c++
Control structures in c++
 
Friend Function
Friend FunctionFriend Function
Friend Function
 
Decision Making and Looping
Decision Making and LoopingDecision Making and Looping
Decision Making and Looping
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Modular programming
Modular programmingModular programming
Modular programming
 
Built in exceptions
Built in exceptions Built in exceptions
Built in exceptions
 
Polymorphism in c++(ppt)
Polymorphism in c++(ppt)Polymorphism in c++(ppt)
Polymorphism in c++(ppt)
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
SQL Joinning.Database
SQL Joinning.DatabaseSQL Joinning.Database
SQL Joinning.Database
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
 
Trigger in DBMS
Trigger in DBMSTrigger in DBMS
Trigger in DBMS
 
Interface in java
Interface in javaInterface in java
Interface in java
 

Destaque

Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Bhushan Mulmule
 
scanf function in c, variations in conversion specifier
scanf function in c, variations in conversion specifierscanf function in c, variations in conversion specifier
scanf function in c, variations in conversion specifierherosaikiran
 
Dependency injection for beginners
Dependency injection for beginnersDependency injection for beginners
Dependency injection for beginnersBhushan Mulmule
 
Implementing auto complete using JQuery
Implementing auto complete using JQueryImplementing auto complete using JQuery
Implementing auto complete using JQueryBhushan Mulmule
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data typesManisha Keim
 
Windows Forms For Beginners Part - 4
Windows Forms For Beginners Part - 4Windows Forms For Beginners Part - 4
Windows Forms For Beginners Part - 4Bhushan Mulmule
 
Windows Forms For Beginners Part - 2
Windows Forms For Beginners Part - 2Windows Forms For Beginners Part - 2
Windows Forms For Beginners Part - 2Bhushan Mulmule
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structsSaad Sheikh
 
Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Bhushan Mulmule
 
Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1Bhushan Mulmule
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array pptsandhya yadav
 
Chap3 flow charts
Chap3 flow chartsChap3 flow charts
Chap3 flow chartsamit139
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programmingManoj Tyagi
 

Destaque (16)

Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5Windows Forms For Beginners Part 5
Windows Forms For Beginners Part 5
 
NInject - DI Container
NInject - DI ContainerNInject - DI Container
NInject - DI Container
 
scanf function in c, variations in conversion specifier
scanf function in c, variations in conversion specifierscanf function in c, variations in conversion specifier
scanf function in c, variations in conversion specifier
 
Dependency injection for beginners
Dependency injection for beginnersDependency injection for beginners
Dependency injection for beginners
 
Implementing auto complete using JQuery
Implementing auto complete using JQueryImplementing auto complete using JQuery
Implementing auto complete using JQuery
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
 
1.3 data types
1.3 data types1.3 data types
1.3 data types
 
Windows Forms For Beginners Part - 4
Windows Forms For Beginners Part - 4Windows Forms For Beginners Part - 4
Windows Forms For Beginners Part - 4
 
Windows Forms For Beginners Part - 2
Windows Forms For Beginners Part - 2Windows Forms For Beginners Part - 2
Windows Forms For Beginners Part - 2
 
C data types, arrays and structs
C data types, arrays and structsC data types, arrays and structs
C data types, arrays and structs
 
Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part - 3
 
Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1Windows Forms For Beginners Part - 1
Windows Forms For Beginners Part - 1
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Computer Programming- Lecture 5
Computer Programming- Lecture 5 Computer Programming- Lecture 5
Computer Programming- Lecture 5
 
Chap3 flow charts
Chap3 flow chartsChap3 flow charts
Chap3 flow charts
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 

Semelhante a Arrays, Structures And Enums

20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstractionIntro C# Book
 
CBSE Grade12, Computer Science, Sample Question Paper
CBSE Grade12, Computer Science, Sample Question PaperCBSE Grade12, Computer Science, Sample Question Paper
CBSE Grade12, Computer Science, Sample Question PaperMalathi Senthil
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxSirRafiLectures
 
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)PROIDEA
 
Generics in .NET, C++ and Java
Generics in .NET, C++ and JavaGenerics in .NET, C++ and Java
Generics in .NET, C++ and JavaSasha Goldshtein
 
Attributes & .NET components
Attributes & .NET componentsAttributes & .NET components
Attributes & .NET componentsBình Trọng Án
 
Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*Intel® Software
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings imtiazalijoono
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsHCMUTE
 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notesGOKULKANNANMMECLECTC
 

Semelhante a Arrays, Structures And Enums (20)

ASP.NET
ASP.NETASP.NET
ASP.NET
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
CBSE Grade12, Computer Science, Sample Question Paper
CBSE Grade12, Computer Science, Sample Question PaperCBSE Grade12, Computer Science, Sample Question Paper
CBSE Grade12, Computer Science, Sample Question Paper
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptx
 
Basic c#
Basic c#Basic c#
Basic c#
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Unit 3
Unit 3 Unit 3
Unit 3
 
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
 
Intake 38 3
Intake 38 3Intake 38 3
Intake 38 3
 
Generics in .NET, C++ and Java
Generics in .NET, C++ and JavaGenerics in .NET, C++ and Java
Generics in .NET, C++ and Java
 
Attributes & .NET components
Attributes & .NET componentsAttributes & .NET components
Attributes & .NET components
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
C#2
C#2C#2
C#2
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Doc 20180130-wa0006
Doc 20180130-wa0006Doc 20180130-wa0006
Doc 20180130-wa0006
 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notes
 
CH1 ARRAY (1).pptx
CH1 ARRAY (1).pptxCH1 ARRAY (1).pptx
CH1 ARRAY (1).pptx
 

Mais de Bhushan Mulmule

Mais de Bhushan Mulmule (7)

Understanding Interfaces
Understanding InterfacesUnderstanding Interfaces
Understanding Interfaces
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Inheritance
InheritanceInheritance
Inheritance
 
Methods
MethodsMethods
Methods
 
Flow Control (C#)
Flow Control (C#)Flow Control (C#)
Flow Control (C#)
 
Getting started with C# Programming
Getting started with C# ProgrammingGetting started with C# Programming
Getting started with C# Programming
 
Overview of .Net Framework 4.5
Overview of .Net Framework 4.5Overview of .Net Framework 4.5
Overview of .Net Framework 4.5
 

Último

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...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
 

Último (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Arrays, Structures And Enums

  • 3. Agenda  Single Dimensional Array  Array Class  Array of Reference Type  Double Dimensional Array  Jagged Array  Structure  Enum www.dotnetvideotutorial.com
  • 4. Array  Data structure holding multiple values of same data-type  Are reference type  Derived from abstract base class Array 20 50 60 0 1 2 Arrays are zero indexed Last index is always (size – 1) 5000 5000 marks www.dotnetvideotutorial.com
  • 5. Array Declarations // Declare a single-dimensional array int[] array1 = new int[5]; // Declare and set array element values, Size can be skipped int[] array2 = new int[] { 1, 3, 5, 7, 9 }; // Alternative syntax. new keyword can be skipped int[] array3 = { 1, 3, 5, 7, 9 }; // Declaration and instantiation on separate lines int[] array4; array4 = new int[5]; 5000 5000 array1 0 1 2 3 4 www.dotnetvideotutorial.com
  • 6. 0 0 0 int[] marks = new int[3]; Console.WriteLine("Enter marks in three subjects:"); for (int i = 0; i < 3; i++) marks[i] = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Marks obtained:"); Console.WriteLine("Printed using for loop"); for (int i = 0; i < 3; i++) Console.WriteLine(marks[i]); Console.WriteLine("Printed using foreach loop"); foreach (int m in marks) { Console.WriteLine(m); } 20 50 60 5000 5000 marks The default value for elements of numeric array is zero 0 1 2 Single Dimensional Array www.dotnetvideotutorial.com
  • 7. Array Class  Base class for all arrays in the common language runtime.  Provides methods for creating, manipulating, searching, and sorting arrays www.dotnetvideotutorial.com
  • 8. Array Class int[] numbers = { 78, 54, 76, 23, 87 }; //sorting Array.Sort(numbers); Console.WriteLine("sorted array: "); for (int i = 0; i < numbers.Length; i++) Console.WriteLine(numbers[i]); //reversing Array.Reverse(numbers); ... //finding out index int index = Array.IndexOf(numbers, 54); Console.WriteLine("Index of 54: " + index); www.dotnetvideotutorial.com
  • 9. Array of Reference Types static void Main(string[] args) { string[] computers = { "Titan", "Mira", "K computer" }; Console.WriteLine("Fastest Super Computers: n"); foreach (string n in computers) { Console.WriteLine(n); } } 2000 2200 1800 Titan Mira K Computer 2000 1800 2200 5000 5000 Computers Note: Default value for elements of reference array is null
  • 10. int[,] marks = new int[3, 4]; for (int i = 0; i < 3; i++) { C.WL("Enter marks in 4 subjects of Student {0}", i + 1); for (int j = 0; j < 4; j++) { marks[i, j] = Convert.ToInt32(Console.ReadLine()); } } 0 0 0 0 0 0 0 0 0 0 0 0 40 50 60 70 80 90 70 80 30 50 80 70 0 1 2 0 1 2 3 2D Array www.dotnetvideotutorial.com
  • 11. Console.WriteLine("---------------Score Board------------------"); for (int i = 0; i < 3; i++) { Console.Write("Student {0}:tt", i + 1); for (int j = 0; j < 4; j++) { Console.Write(marks[i, j] + "t"); } Console.WriteLine(); } 0 0 0 0 0 0 0 0 0 0 0 0 40 50 60 70 80 90 70 80 30 50 80 70 0 1 2 0 1 2 3 2D Array www.dotnetvideotutorial.com
  • 12. Jagged Array  Array of Arrays: A jagged array is an array whose elements are arrays.  The elements of a jagged array can be of different dimensions and sizes.  Syntax: type[][] identifier = new type[size][]; www.dotnetvideotutorial.com
  • 13. Jagged Array int[][] a = new int[3][]; a[0] = new int[2] { 32, 54 }; a[1] = new int[4] { 78, 96, 46, 38 }; a[2] = new int[3] { 54, 76, 23 }; 2000 1800 2200 5000 5000 a 2000 2200 1800 32 54 54 76 23 78 96 46 38
  • 14. for (int i = 0; i < 3; i++) { for (int j = 0; j < a[i].Length; j++) { Console.Write(a[i][j] + "t"); } Console.WriteLine(); } 2000 1800 2200 5000 5000 a 2000 2200 1800 32 54 54 76 23 78 96 46 38
  • 15. Struct  Keyword to create user defined datatype  Typically used to encapsulate small groups of related variables  A struct type is a value type  Structs can implement an interface but can't inherit from another struct or class. NOTE: structs can contain constructors, constants, fields, methods, properties, indexers, operators, events, and nested types, although if several such members are required, consider making your type a class instead.
  • 16. struct Point { public int x; public int y; } class Program { static void Main(string[] args) { Point p1; Console.WriteLine("Enter X and Y axis of point:"); p1.x = Convert.ToInt32(Console.ReadLine()); p1.y = Convert.ToInt32(Console.ReadLine()); C.WL("Coordinates of p1: x = {0}, y = {1}", p1.x, p1.y); Console.ReadKey(); } } 0 0 p1 x y 10 20 www.dotnetvideotutorial.com
  • 17. Enum enum Gender { Male, Female, Other } Gender g1 = Gender.Female; 1 g1 www.dotnetvideotutorial.com
  • 18. Enums  The enum keyword is used to declare an enumeration, a distinct type consisting of a set of named constants called the enumerator list.  The default underlying type of the enumeration elements is int.  By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1. www.dotnetvideotutorial.com
  • 19. enum Gender { Male = 10, Female, Other } class Program { static void Main(string[] args) { Gender g1 = Gender.Female; C.WL("g1 represents {0}. But value stored is {1}", g1, (int)g1); Gender g2 = Gender.Male; C.WL("g2 represents {0}. But value stored is {1}", g2, (int)g2); } } 11 10 g1 g2 www.dotnetvideotutorial.com