SlideShare a Scribd company logo
1 of 5
Indexers are one flawless component of C#. They
permit us to get to a specific class as it is an
array. They are like the properties such that they
typify or encapsulate the calls to the methods
into more advantageous representation of quality
accessing in setting the values. In order to
declare a property, we can use it by the name.
The indexer is no more dissimilar to class, so it
exhibits a type, i.e. you need to pronounce a
variable of its sort (by instantiating the object
type). Indexers are likewise called smart arrays in
C# and can be utilized to regard our object as
an array(a type having elements of same type).
An indexer permits a class instance or a struct to
be indexed like the way through which the array
is accessed by LOOPING etc
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IndexerExample
{
public class WelcomeMessage
{
public static string[] messageelements = new string[5];
public WelcomeMessage()
{
for (int i = 0; i < messageelements.Length; i++)
messageelements[i] = String.Format("{0}", i);
}
public string this[ int myIndexer]
{
get
{
string tmp;
if (myIndexer >= 0 && myIndexer <=
messageelements.Length - 1)
tmp = messageelements[myIndexer];
else
tmp = "";
return (tmp);
}
set
{
if (myIndexer >= 0 && myIndexer <=
messageelements.Length - 1)
messageelements[myIndexer] = value;
}
}}
public class Program
{
public static void Main()
{
WelcomeMessage elements = new WelcomeMessage();
elements[0] = "Hello! ";
elements[1] = "How ";
elements[2] = "are ";
elements[3] = "you ";
elements[4] = "today?";
for (int i = 0; i < WelcomeMessage.messageelements.Length; i++)
Console.Write(elements[i]);
Console.ReadLine();
}
}
}
Hello! How are you today?

More Related Content

What's hot

Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
ย 
Learn C# Programming - Structure & Enums
Learn C# Programming - Structure & EnumsLearn C# Programming - Structure & Enums
Learn C# Programming - Structure & EnumsEng Teong Cheah
ย 
C++ with student management system project
C++ with student management system projectC++ with student management system project
C++ with student management system projectKratik Khandelwal
ย 
Basic concept of Object Oriented Programming
Basic concept of Object Oriented Programming Basic concept of Object Oriented Programming
Basic concept of Object Oriented Programming Prognoz Technologies Pvt. Ltd.
ย 
Semantic DEX Components
Semantic DEX ComponentsSemantic DEX Components
Semantic DEX ComponentsDavid Price
ย 
object oriented programming using c++
 object oriented programming using c++ object oriented programming using c++
object oriented programming using c++fasalsial1fasalsial1
ย 
(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHP(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHPRick Ogden
ย 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS abhishek kumar
ย 
Oo ps concepts in c++
Oo ps concepts in c++Oo ps concepts in c++
Oo ps concepts in c++Hemant Saini
ย 
Encapsulation
EncapsulationEncapsulation
EncapsulationFALLEE31188
ย 
150950107056 2150704
150950107056 2150704150950107056 2150704
150950107056 2150704Prashant Mokani
ย 
Constant a,variables and data types
Constant a,variables and data typesConstant a,variables and data types
Constant a,variables and data typesmithilesh kumar
ย 
Design Patterns - 03 Composite and Flyweight Pattern
Design Patterns - 03 Composite and Flyweight PatternDesign Patterns - 03 Composite and Flyweight Pattern
Design Patterns - 03 Composite and Flyweight Patterneprafulla
ย 
PCSTt11 overview of java
PCSTt11 overview of javaPCSTt11 overview of java
PCSTt11 overview of javaArchana Gopinath
ย 
Lecture 2
Lecture 2Lecture 2
Lecture 2emailharmeet
ย 
Hibernate Training Session1
Hibernate Training Session1Hibernate Training Session1
Hibernate Training Session1Asad Khan
ย 

What's hot (20)

Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
ย 
Learn C# Programming - Structure & Enums
Learn C# Programming - Structure & EnumsLearn C# Programming - Structure & Enums
Learn C# Programming - Structure & Enums
ย 
C++ with student management system project
C++ with student management system projectC++ with student management system project
C++ with student management system project
ย 
Ashish oot
Ashish ootAshish oot
Ashish oot
ย 
Basic concept of Object Oriented Programming
Basic concept of Object Oriented Programming Basic concept of Object Oriented Programming
Basic concept of Object Oriented Programming
ย 
Oops
OopsOops
Oops
ย 
CIS266 Midterm Review
CIS266 Midterm ReviewCIS266 Midterm Review
CIS266 Midterm Review
ย 
Semantic DEX Components
Semantic DEX ComponentsSemantic DEX Components
Semantic DEX Components
ย 
object oriented programming using c++
 object oriented programming using c++ object oriented programming using c++
object oriented programming using c++
ย 
(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHP(An Extended) Beginners Guide to Object Orientation in PHP
(An Extended) Beginners Guide to Object Orientation in PHP
ย 
Oops
OopsOops
Oops
ย 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS
ย 
Oo ps concepts in c++
Oo ps concepts in c++Oo ps concepts in c++
Oo ps concepts in c++
ย 
Encapsulation
EncapsulationEncapsulation
Encapsulation
ย 
150950107056 2150704
150950107056 2150704150950107056 2150704
150950107056 2150704
ย 
Constant a,variables and data types
Constant a,variables and data typesConstant a,variables and data types
Constant a,variables and data types
ย 
Design Patterns - 03 Composite and Flyweight Pattern
Design Patterns - 03 Composite and Flyweight PatternDesign Patterns - 03 Composite and Flyweight Pattern
Design Patterns - 03 Composite and Flyweight Pattern
ย 
PCSTt11 overview of java
PCSTt11 overview of javaPCSTt11 overview of java
PCSTt11 overview of java
ย 
Lecture 2
Lecture 2Lecture 2
Lecture 2
ย 
Hibernate Training Session1
Hibernate Training Session1Hibernate Training Session1
Hibernate Training Session1
ย 

Viewers also liked

Indexing Techniques: Their Usage in Search Engines for Information Retrieval
Indexing Techniques: Their Usage in Search Engines for Information RetrievalIndexing Techniques: Their Usage in Search Engines for Information Retrieval
Indexing Techniques: Their Usage in Search Engines for Information RetrievalVikas Bhushan
ย 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for filesZainab Almugbel
ย 
Database indexing techniques
Database indexing techniquesDatabase indexing techniques
Database indexing techniquesahmadmughal0312
ย 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp PresentationVishwa Mohan
ย 
Introduction to indexing (presentation1)
Introduction to indexing (presentation1)Introduction to indexing (presentation1)
Introduction to indexing (presentation1)Mary May Porto
ย 
Data indexing presentation
Data indexing presentationData indexing presentation
Data indexing presentationgmbmanikandan
ย 
1. indexing and abstracting
1. indexing and abstracting1. indexing and abstracting
1. indexing and abstractingMoses Mbanje
ย 
Indexing and-hashing
Indexing and-hashingIndexing and-hashing
Indexing and-hashingAmi Ranjit
ย 
Introduction to indexing
Introduction to indexingIntroduction to indexing
Introduction to indexingDaryl Superio
ย 
Electronic records management
Electronic records managementElectronic records management
Electronic records managementKirti Joshi
ย 
Indexing Data Structure
Indexing Data StructureIndexing Data Structure
Indexing Data StructureVivek Kantariya
ย 
Records management ppt
Records management pptRecords management ppt
Records management pptAimee Pusing
ย 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net frameworkThen Murugeshwari
ย 
Filing and record keeping
Filing and record keepingFiling and record keeping
Filing and record keepingmahamed_11
ย 
key word indexing and their types with example
key word indexing and their types with example key word indexing and their types with example
key word indexing and their types with example Sourav Sarkar
ย 

Viewers also liked (18)

Indexing Techniques: Their Usage in Search Engines for Information Retrieval
Indexing Techniques: Their Usage in Search Engines for Information RetrievalIndexing Techniques: Their Usage in Search Engines for Information Retrieval
Indexing Techniques: Their Usage in Search Engines for Information Retrieval
ย 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for files
ย 
Database indexing techniques
Database indexing techniquesDatabase indexing techniques
Database indexing techniques
ย 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
ย 
Introduction to indexing (presentation1)
Introduction to indexing (presentation1)Introduction to indexing (presentation1)
Introduction to indexing (presentation1)
ย 
Data indexing presentation
Data indexing presentationData indexing presentation
Data indexing presentation
ย 
1. indexing and abstracting
1. indexing and abstracting1. indexing and abstracting
1. indexing and abstracting
ย 
Indexing and-hashing
Indexing and-hashingIndexing and-hashing
Indexing and-hashing
ย 
Introduction to indexing
Introduction to indexingIntroduction to indexing
Introduction to indexing
ย 
Indexing
IndexingIndexing
Indexing
ย 
Indexing
IndexingIndexing
Indexing
ย 
Electronic records management
Electronic records managementElectronic records management
Electronic records management
ย 
File And Records Management
File And Records ManagementFile And Records Management
File And Records Management
ย 
Indexing Data Structure
Indexing Data StructureIndexing Data Structure
Indexing Data Structure
ย 
Records management ppt
Records management pptRecords management ppt
Records management ppt
ย 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net framework
ย 
Filing and record keeping
Filing and record keepingFiling and record keeping
Filing and record keeping
ย 
key word indexing and their types with example
key word indexing and their types with example key word indexing and their types with example
key word indexing and their types with example
ย 

Similar to Indexers in C#

CSharp for Unity Day 3
CSharp for Unity Day 3CSharp for Unity Day 3
CSharp for Unity Day 3Duong Thanh
ย 
C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01Zafor Iqbal
ย 
Structures in c language
Structures in c languageStructures in c language
Structures in c languageTanmay Modi
ย 
Structures in c language
Structures in c languageStructures in c language
Structures in c languagetanmaymodi4
ย 
Properties and Indexers
Properties and IndexersProperties and Indexers
Properties and IndexersDhrumil Panchal
ย 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Javabackdoor
ย 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceEng Teong Cheah
ย 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegantalenttransform
ย 
Java defining classes
Java defining classes Java defining classes
Java defining classes Mehdi Ali Soltani
ย 
Class properties
Class propertiesClass properties
Class propertiesSiva Priya
ย 
Module 14 properties and indexers
Module 14 properties and indexersModule 14 properties and indexers
Module 14 properties and indexersPrem Kumar Badri
ย 
Pavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile DevelopmentPavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile DevelopmentCiklum
ย 
Classes,object and methods java
Classes,object and methods javaClasses,object and methods java
Classes,object and methods javaPadma Kannan
ย 
C# concepts
C# conceptsC# concepts
C# conceptslexilijoseph
ย 

Similar to Indexers in C# (20)

CSharp for Unity Day 3
CSharp for Unity Day 3CSharp for Unity Day 3
CSharp for Unity Day 3
ย 
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
ย 
C# interview
C# interviewC# interview
C# interview
ย 
C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01
ย 
C# program structure
C# program structureC# program structure
C# program structure
ย 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
ย 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
ย 
Properties and Indexers
Properties and IndexersProperties and Indexers
Properties and Indexers
ย 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
ย 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & Inheritance
ย 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegan
ย 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
ย 
Java defining classes
Java defining classes Java defining classes
Java defining classes
ย 
Class properties
Class propertiesClass properties
Class properties
ย 
Array_Class_11_CBSE_notes
Array_Class_11_CBSE_notesArray_Class_11_CBSE_notes
Array_Class_11_CBSE_notes
ย 
Module 14 properties and indexers
Module 14 properties and indexersModule 14 properties and indexers
Module 14 properties and indexers
ย 
Pavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile DevelopmentPavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile Development
ย 
Classes,object and methods java
Classes,object and methods javaClasses,object and methods java
Classes,object and methods java
ย 
C# concepts
C# conceptsC# concepts
C# concepts
ย 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
ย 

More from AA Coaching Academy

Programming in c plus plus4
Programming in c plus plus4Programming in c plus plus4
Programming in c plus plus4AA Coaching Academy
ย 
Programming in c plus plus3
Programming in c plus plus3Programming in c plus plus3
Programming in c plus plus3AA Coaching Academy
ย 
Programming in c plus plus2
Programming in c plus plus2Programming in c plus plus2
Programming in c plus plus2AA Coaching Academy
ย 
Advanced interview questions
Advanced interview questionsAdvanced interview questions
Advanced interview questionsAA Coaching Academy
ย 
Programming interview questions
Programming interview questionsProgramming interview questions
Programming interview questionsAA Coaching Academy
ย 
Professional erd models
Professional erd modelsProfessional erd models
Professional erd modelsAA Coaching Academy
ย 

More from AA Coaching Academy (7)

New rich text document
New rich text documentNew rich text document
New rich text document
ย 
Programming in c plus plus4
Programming in c plus plus4Programming in c plus plus4
Programming in c plus plus4
ย 
Programming in c plus plus3
Programming in c plus plus3Programming in c plus plus3
Programming in c plus plus3
ย 
Programming in c plus plus2
Programming in c plus plus2Programming in c plus plus2
Programming in c plus plus2
ย 
Advanced interview questions
Advanced interview questionsAdvanced interview questions
Advanced interview questions
ย 
Programming interview questions
Programming interview questionsProgramming interview questions
Programming interview questions
ย 
Professional erd models
Professional erd modelsProfessional erd models
Professional erd models
ย 

Recently uploaded

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
ย 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
ย 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
ย 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
ย 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
ย 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
ย 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
ย 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
ย 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
ย 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
ย 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
ย 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
ย 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
ย 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
ย 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
ย 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
ย 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
ย 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
ย 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
ย 

Recently uploaded (20)

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
ย 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
ย 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
ย 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
ย 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
ย 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
ย 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
ย 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
ย 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
ย 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
ย 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
ย 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
ย 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
ย 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ย 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
ย 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
ย 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
ย 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
ย 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
ย 

Indexers in C#

  • 1. Indexers are one flawless component of C#. They permit us to get to a specific class as it is an array. They are like the properties such that they typify or encapsulate the calls to the methods into more advantageous representation of quality accessing in setting the values. In order to declare a property, we can use it by the name. The indexer is no more dissimilar to class, so it exhibits a type, i.e. you need to pronounce a variable of its sort (by instantiating the object type). Indexers are likewise called smart arrays in C# and can be utilized to regard our object as an array(a type having elements of same type). An indexer permits a class instance or a struct to be indexed like the way through which the array is accessed by LOOPING etc
  • 2. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IndexerExample { public class WelcomeMessage { public static string[] messageelements = new string[5]; public WelcomeMessage() { for (int i = 0; i < messageelements.Length; i++) messageelements[i] = String.Format("{0}", i); }
  • 3. public string this[ int myIndexer] { get { string tmp; if (myIndexer >= 0 && myIndexer <= messageelements.Length - 1) tmp = messageelements[myIndexer]; else tmp = ""; return (tmp); } set { if (myIndexer >= 0 && myIndexer <= messageelements.Length - 1) messageelements[myIndexer] = value; } }}
  • 4. public class Program { public static void Main() { WelcomeMessage elements = new WelcomeMessage(); elements[0] = "Hello! "; elements[1] = "How "; elements[2] = "are "; elements[3] = "you "; elements[4] = "today?"; for (int i = 0; i < WelcomeMessage.messageelements.Length; i++) Console.Write(elements[i]); Console.ReadLine(); } } }
  • 5. Hello! How are you today?