C # Indexer

Source: Internet
Author: User

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Runtime.InteropServices;5 usingSystem.Text;6 7 namespaceclasstrining8 {9     classDemoTen     { One         //=============== Property ============================================= A         //declaring private fields -         Private string_name ="Mike"; -         /// <summary> the         ///declaring Properties -         /// </summary> -          Public stringName -         { +             Get -             { +                 //returns the private field value of the Declaration A                 return_name; at             } -             Set -             { -                 //use fields to save user-set values -_name =value; -             } in         } -         //=============== Property ============================================= to  +  -         //=============== Indexer ============================================= the         //declaring an array of strings *         string[] Strarray =New string[ -]; $         /// <summary>Panax Notoginseng         ///declares a string type indexer this is used to manipulate an array of strings and to find values by index -         /// </summary> the         /// <param name= "i" ></param> +         /// <returns></returns> A          Public string  This[inti] the         { +             Get -             { $                 //returns the specified index value of an array $                 returnStrarray[i]; -             } -             Set the             { -                 //change the value of the index position with the array and save the user setting valueWuyiStrarray[i] =value; the             } -         } Wu         //=============== Indexer ============================================= -  About     } $  -  -     classMijk -     { A         Private stringName ="Lihong"; +  the  -          Public stringName $         { the             Get the             { the                 returnname; the             } -             Set in             { theName =value; the             } About         } the  the         Private string[] Meli =New string[ -]; the          +  -          Public string  This[inti] the         {Bayi             Get the             { the                 returnMeli[i]; -             } -             Set the             { theMeli[i] =value; the             } the         } -  the          Public voidTest () the         { themeli[0] ="Hello";94meli[1] ="kity"; themeli[2] ="CSharp"; themeli[ A] ="Studio"; the 98             stringstr = meli[2]; About  - 101meli[ About] ="NOKIA";102 103             stringNokia = meli[ About];104         } the 106 107 108 109  the     }111      the     113      the}

C # Indexer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.