久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

索引示例

 修行的嘟嘟 2010-04-17
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Property
{
    class Program
    {
        static void Main(string[] args)
        {
            Myclass class1 = new Myclass();
            for (int i = 0; i < 10; i++)
            {
                for (int j=0;j<10;j++)
                {
                    class1[i * 10, j] = i * 10 + j;
                    Console.WriteLine("No{0}{1}:{2}", i, j, class1[i * 10, j]);
                }
                Console.WriteLine();
            }
            for (int i = 0; i < class1.StrCount; i++)
            {
                Console.WriteLine(class1[i]);//調(diào)用第二個索引
            }
            class1.StrCount = 5;//設(shè)置StrCount值
            for (int i = 0; i < class1.StrCount; i++)
            {
                Console.WriteLine(class1[i]);//調(diào)用第二個索引
            }
            Console.WriteLine(Myclass.ClassName);//調(diào)用靜態(tài)方法時必須用類名對象調(diào)用
            Console.Write("Press any key to continue");
            Console.ReadLine();
        }
    }
    class Myclass
    {
        private const int count = 100;
        private static int[] intArray = new int[count];
        //第一個索引函數(shù),,支持讀和寫
        public int this[int index, int offset]
        {
            get
            {
                if ((index + offset) > 0 && (index + offset) < count)
                {
                    return intArray[index + offset];
                }
                else
                    return 0;
            }
            set
            {
                if ((index + offset) > 0 && (index + offset) < count)
                {
                    intArray[index + offset] = value;
                }
            }
        }
        private int count1 = 3;
        private string[] strArray = {"111","222","333" };//直接賦值法
        //第二個索引,,只讀
        public string this[int index]
        {
            get
            {
                if ((index) > 0 && (index) < count1)
                {
                    return strArray[index];
                }
                else
                {
                    return "null";
                }
            }
        }
        //實例屬性可讀可寫
        public int StrCount
        {
            get
            {
                return count1;
            }
            set
            {
                if (value > count1)
                {
                    strArray=new string[value];
                    for (int i = 0; i < value; i++)
                    {
                        strArray[i] = string.Format("String NO.{0}",i);
                    }
                    count1 = value;
                }
            }
        }
        private static string str = "MyClass";
        public static string ClassName
        {
            get
            {
                return str;
            }
        }
    }
}

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點,。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多