SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend classAbhishek Wadhwa
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in javaHitesh Kumar
 
Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++Hitesh Kumar
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C v_jk
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)Ritika Sharma
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphismlalithambiga kamaraj
 
Authentication
AuthenticationAuthentication
Authenticationsoon
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingabhay singh
 
Inline function
Inline functionInline function
Inline functionTech_MX
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++LPU
 
Function in c program
Function in c programFunction in c program
Function in c programumesh patil
 
06. operator overloading
06. operator overloading06. operator overloading
06. operator overloadingHaresh Jaiswal
 

Was ist angesagt? (20)

Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
 
Constructor and destructor
Constructor  and  destructor Constructor  and  destructor
Constructor and destructor
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
 
Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
 
Authentication
AuthenticationAuthentication
Authentication
 
Method overriding
Method overridingMethod overriding
Method overriding
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Inline function
Inline functionInline function
Inline function
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
Template C++ OOP
Template C++ OOPTemplate C++ OOP
Template C++ OOP
 
User Defined Functions
User Defined FunctionsUser Defined Functions
User Defined Functions
 
16717 functions in C++
16717 functions in C++16717 functions in C++
16717 functions in C++
 
Files and streams
Files and streamsFiles and streams
Files and streams
 
Function in c program
Function in c programFunction in c program
Function in c program
 
06. operator overloading
06. operator overloading06. operator overloading
06. operator overloading
 
Function in c
Function in cFunction in c
Function in c
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von Bhushan Mulmule

Mehr von 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
 

Kürzlich hochgeladen

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
🐬 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
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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
 
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...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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 

Kürzlich hochgeladen (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
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...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...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

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