• 大小: 0.02M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-02-26
  • 语言: C#
  • 标签:

资源简介

C#实例方法的调用

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _3._3
{
    class sampleIndex
    {
        private double[] arr = new double[5] { 1 2 3 4 5 };
        public double this[int index]
        {
            get
            {
                if (index < 0 || index >= 5)
                {
                    return 0;
                }
                else
                {
                    return arr[index];
                }
            }
            set
            {

                if (index >= 0 && index <= 5)
                {
                    arr[index] = value;
                }
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            sampleIndex smpIndex = new sampleIndex();
            smpIndex[3] = 3.5;
            for (int i = 0; i < 6; i++)
            {
                Console.WriteLine(“smpIndex[{0}]={1}“ i smpIndex[

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2429  2015-09-29 09:15  3.3\3.3\3.3.csproj

     文件       5632  2015-09-29 09:25  3.3\3.3\bin\Debug\3.3.exe

     文件      13824  2015-09-29 09:25  3.3\3.3\bin\Debug\3.3.pdb

     文件      11600  2015-09-29 09:25  3.3\3.3\bin\Debug\3.3.vshost.exe

     文件        192  2015-09-29 09:25  3.3\3.3\obj\x86\Debug\3.3.csproj.FileListAbsolute.txt

     文件       5632  2015-09-29 09:25  3.3\3.3\obj\x86\Debug\3.3.exe

     文件      13824  2015-09-29 09:25  3.3\3.3\obj\x86\Debug\3.3.pdb

     文件       5833  2015-09-29 09:25  3.3\3.3\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1078  2015-09-29 09:36  3.3\3.3\Program.cs

     文件       1338  2015-09-29 09:15  3.3\3.3\Properties\AssemblyInfo.cs

     文件        851  2015-09-29 09:15  3.3\3.3.sln

    ..A..H.     15872  2015-09-29 09:36  3.3\3.3.suo

     目录          0  2015-09-29 09:15  3.3\3.3\obj\x86\Debug\TempPE

     目录          0  2015-09-29 09:25  3.3\3.3\obj\x86\Debug

     目录          0  2015-09-29 09:25  3.3\3.3\bin\Debug

     目录          0  2015-09-29 09:15  3.3\3.3\bin\Release

     目录          0  2015-09-29 09:15  3.3\3.3\obj\x86

     目录          0  2015-09-29 09:15  3.3\3.3\bin

     目录          0  2015-09-29 09:15  3.3\3.3\obj

     目录          0  2015-09-29 09:15  3.3\3.3\Properties

     目录          0  2015-09-29 09:15  3.3\3.3

     目录          0  2015-09-29 09:15  3.3

----------- ---------  ---------- -----  ----

                78105                    22


评论

共有 条评论