索引器的使用
来源:互联网 发布:v2ex源码搭建 编辑:程序博客网 时间:2024/06/07 04:08
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 索引器
{
class Program
{
static void Main(string[] args)
{
MyIndexer myindexer1 = new MyIndexer();
myindexer1[2] = 22;
myindexer1[4] = 44;
for (int i = 0; i < 5; i++)
{
Console.WriteLine("myindexer1[{0}]={1}", i, myindexer1[i]);
}
}
}
class MyIndexer
{
private int[] arr = new int[5]{0,1,2,3,4};
public int this[int index]
{
get
{
if (index >= 0 && index < 5) return arr[index];
else return 0;
}
set
{
if (index >= 0 && index < 5)
arr[index] = value;
}
}
public int Length
{
get { return arr.Length; }
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 索引器
{
class Program
{
static void Main(string[] args)
{
MyIndexer myindexer1 = new MyIndexer();
myindexer1[2] = 22;
myindexer1[4] = 44;
for (int i = 0; i < 5; i++)
{
Console.WriteLine("myindexer1[{0}]={1}", i, myindexer1[i]);
}
}
}
class MyIndexer
{
private int[] arr = new int[5]{0,1,2,3,4};
public int this[int index]
{
get
{
if (index >= 0 && index < 5) return arr[index];
else return 0;
}
set
{
if (index >= 0 && index < 5)
arr[index] = value;
}
}
public int Length
{
get { return arr.Length; }
}
}
}
0 0
- 索引器的使用
- 索引器的使用
- 索引器的使用
- 索引器的使用
- 索引器的使用
- C#索引器的使用
- 索引器!!的其他使用!
- 索引器、枚举的使用
- 使用索引器的优点
- c#索引器的使用
- C#索引器的使用
- C# 索引器的使用
- c#中索引器的使用
- 索引器与迭代器的使用
- c#中索引器的使用
- C# 类中索引器的使用
- C# 类中索引器的使用
- C# 类中索引器的使用
- 异或求校验和
- spring->动态代理
- Introduction to Algorithm 3rd Edition
- requests不容易注意到的细节收集~
- 服务器优化说明
- 索引器的使用
- 关于UNION查询的排序问题
- TCL 语言初接触
- Imx6Q Uboot 3.14.52
- POJ 1835 宇航员
- DNS协议 : RFC1035 中文
- 百度推送
- select模型
- POJ Area (pick)