.Net Practical 13


Practical : 13
Subject : .Net

Aim : Write a C# program to demonstrate the usage of Indexer.



Source Code :
using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace dotnet008
{
    class pra13
    {
        public string[] info = new string[4];
        public string this[int index]
        {
            get
            {
                return info[index];
            }
            set
            {
                info[index] = value;
            }
        }
        static void Main(string[] ar)
        {
            pra13 p1 = new pra13();
            p1[0] = "pratik";
            p1[1] = "boghani";
            p1[2] = "171230107008";
            p1[3] = "computer";
            Console.WriteLine("index 0 : {0} \nindex 1 : {1} \nindex 2 : {2} \nindex 3 : {3}", p1[0], p1[1], p1[2], p1[3]);
            Console.ReadKey();
        }
    }
}

Output : 


Pratik Boghani

Author & Editor

Life is all about the next step.

0 comments:

Post a Comment