RT
一个类有6个数组 如何设置索引 单个的我知道
private string[] test;
public string this[int index]
{
get{return test[index];}
}多个我就不知道了 急
一个类有6个数组 如何设置索引 单个的我知道
private string[] test;
public string this[int index]
{
get{return test[index];}
}多个我就不知道了 急
解决方案 »
- 这个网站的图片处理功能是怎样实现的???
- iframe的问题
- ImagePreView 未定义
- asp如何转aspx
- vbs 每隔20秒访问一个
- a.aspx页Ajax调用一个b.aspx文件显示返回结果,b.aspx如何找到a.aspx的控件呢?
- 单点登陆退出时,认证服务器的退出页面生成的image(指向各应用的退出页面)的cookie被阻挡,如何解决?(ie7)
- TreeView 节点展开后选中问题
- 我在页面里用了一个js仿windows任务栏,是利用层实现的,里面有textbox,但当提交服务器返回数据时,textbox的值就重复显示,怎么回是?
- ACTIVEREPORT 报表预览时PDF版本不同,预览结果不同。
- 请问数据库访问用什么?
- asp.net mvc RenderPartial 显示数据的问题
private string[] test1;
private string[] test2; public void set()
{
list.Insert(0, test1);
list.Insert(1, test2);
}
我挺纳闷的 一个类里面有一个数组 可以用this访问器
多个数组如何设置访问器
using System;namespace TestUse
{
/// <summary>
/// Summary description for Muliti.
/// </summary>
public class Muliti
{
public Muliti()
{
//
// TODO: Add constructor logic here
//
} private string[] test1;
private object[] test2;
private int[] test3; public object this[string arrname,int index]{
get{
switch(arrname){
case "test1":return test1[index];
case "test2":return test2[index];
case "test3":return test3[index];
default:return null;
}
}
set{
switch(arrname)
{
case "test1":test1[index]=value.ToString();break;
case "test2":test2[index]=value;break;
case "test3":test3[index]=(int)value;break;
default:break;
}
}
} public void setUpArray(){
test1 = new string[3];
test2 = new object[2];
test3 = new int[4];
}
}
}测试代码:
private void button1_Click(object sender, System.EventArgs e)
{
Muliti testm = new Muliti();
testm.setUpArray();
testm["test1",0]="test1-0";
testm["test2",0]= "test2-0";
testm["test3",0]= 3;
MessageBox.Show((string)testm["test1",0]);
MessageBox.Show((string)testm["test2",0]);
MessageBox.Show("" + testm["test3",0]);
}