c# 重写索引
//using System.Collections.Generic;
//using System.Text;
//{
// class Program
// {
// static void Main(string[] args)
// {
// }
// }
//}
//using System;
//class MyIndexer
//{ private string [ ] myArray=new string[4];
// public string this[int index]
// { get
// { if(index<0||index>=4)
// return null;
// else
// return myArray[index];
// }
// set
// { if(!(index<0||index>=4))
// myArray[index]=value;
// }
// }
//}
//class MainClass
//{
// static void Main()
// { MyIndexer idx=new MyIndexer();
// idx[0]="vivid";
// idx[1]="Miles";
// for(int i=0;i<=3;i++)
// Console.WriteLine("Element #{0}={1}",i,idx[i]);
// }
//}
//////////////////////////////////////////////
//class SampleCollection<T>
//{
// private T[] arr = new T[100];
// public T this[int i]
// {
// get
// {
// return arr[i];
// }
// set
// {
// arr[i] = value;
// }
// }
//}
//class Program
//{
// static void Main(string[] args)
// {
// SampleCollection<string> stringCollection = new SampleCollection<string>();
// stringCollection[0] = "Hello, World";
// System.Console.WriteLine(stringCollection[0]);
// }
//}
///////////////////////
namespace A
{
class test
{
private int[] arry = new int[5];
//protected int Arry
//{
// get
// {
// for (int i = 0; i < 5; i++)
// {
// return arry[i];
// }
// }
// set
// {
// for (int i = 0; i < 5; i++)
// {
// arry[i] = value;
// }
// }
//}
public int this[int index]
{
get
{
return arry[index];
}
set
{
arry[index] = value;
}
}
}
class print
{
static void Main()
{
test arr = new test();
for (int i = 0; i < 5; i++)
{
arr[i] = i * i;
}
for (int i = 0; i < 5; i++)
{
System.Console.WriteLine("arr[{0}]={1}", i + 1, arr[i]);
}
}
}
}
c# 重写索引的更多相关文章
- 《精通C#》索引器与重载操作符(11.1-11.2)
1.索引器方法结构大致为<modifier><return type> this [argument list],它可以在接口中定义: 在为接口声明索引器的时候,记住声明只是表 ...
- 关于索引删除的策略IndexDeletionPolicy
关于索引删除的策略IndexDeletionPolicy . public IndexWriter(Directory d, Analyzer a, boolean create) ...
- Oracle优化的几个简单步骤
数据库优化的讨论可以说是一个永恒的主题.资深的Oracle优化人员通常会要求提出性能问题的人对数据库做一个statspack,贴出数据库配置等等.还有的人认为要抓出执行最慢的语句来进行优化.但实际情况 ...
- MapReduce: 一种简化的大规模集群数据处理法
(只有文字没有图,图请参考http://research.google.com/archive/mapreduce.html) MapReduce: 一种简化的大规模集群数据处理法 翻译:风里来雨里去 ...
- C# 语言规范_版本5.0 (第10章 类)
1. 类 类是一种数据结构,它可以包含数据成员(常量和字段).函数成员(方法.属性.事件.索引器.运算符.实例构造函数.静态构造函数和析构函数)以及嵌套类型.类类型支持继承,继承是一种机制,它使派生类 ...
- MySql 性能调优策略
本主题调优针对于my.cnf配置来做详细的参数说明 示例配置如下: #cat my.cnf # MySQL client library initialization. [client] port = ...
- C#6.0语言规范(十) 类
类是可以包含数据成员(常量和字段),函数成员(方法,属性,事件,索引器,运算符,实例构造函数,析构函数和静态构造函数)和嵌套类型的数据结构.类类型支持继承,这是一种派生类可以扩展和专门化基类的机制. ...
- Oracle表的优化一点见解
Oracle优化的几个简单步骤 数据库优化的讨论可以说是一个永恒的主题.资深的Oracle优化人员通常会要求提出性能问题的人对数据库做一个statspack,贴出数据库配置等等.还有的人认为要抓出执行 ...
- Pro ASP.Net Core MVC 6th 第四章
第四章 C# 关键特征 在本章中,我描述了Web应用程序开发中使用的C#特征,这些特征尚未被广泛理解或经常引起混淆. 这不是关于C#的书,但是,我仅为每个特征提供一个简单的例子,以便您可以按照本书其余 ...
随机推荐
- Mininet的安装与卸载
1.Mininet的卸载比较简单,只需要执行以下命令: sudo rm -rf /usr/local/bin/mn /usr/local/bin/mnexec /usr/local/lib/pytho ...
- express 笔记 app.helpers 和 app.locals
app.helpers 和app.dynamicHelpers 是express2.X使用的 分别为静态/动态 视图助手通过其注册函数, 例如 app.helpers({ <span style ...
- Visual Studio调试
一:C# CODING 技巧 1:TODO 然后 CTRL + W + T,打开任务列表,选中 Comments,就会显示所有待做的任务 2:打开所在的文件夹 右键单击任何一个文件选项卡, 选择&qu ...
- jqurey 遍历 div内的所有input单选复选按钮并判断是否选中及Attr(checked)无效的解决
关于页面前面标签 <ul> @{ foreach (var item in vote) { if (!string.IsNullOrEmpty(item.Img)) { <li cl ...
- css动画之波纹
样式定义: #ContactAbout { height: auto; position: relative; overflow: hidden; } #sectioncontact { displa ...
- SequoiaDB 系列之七 :源码分析之catalog节点
这一篇紧接着上一篇SequoiaDB 系列之六 :源码分析之coord节点来讲 在上一篇中,分析了coord转发数据包到catalog节点(也有可能是data节点,视情况而定).这一次,我们继续分析上 ...
- HTML5——多次定位请求
多次定位请求及点击一次 就不断的触发请求事件,和单次定位请求写法差不多,只需要将 navigator.geolocation.getCurrentPosition改为navigator.geoloca ...
- 【BZOJ 3143】【Hnoi2013】游走 期望+高斯消元
如果纯模拟,就会死循环,而随着循环每个点的期望会逼近一个值,高斯消元就通过列方正组求出这个值. #include<cstdio> #include<cctype> #inclu ...
- PowerDesigner-导出表到word
1. 在工具栏中选择[Report -->Reports],如下图 2. 点击第二个图标创建一个Report,如下图 该wizard中有三个信息 Report name Report : Rep ...
- jQuery 文本编辑器插件 HtmlBox 使用
0.htmlbox下载地址:http://download.csdn.net/detail/leixiaohua1020/6376479 1.引入头文件 <script src="li ...