比如说我有如下的结构: struct Vector
{
private double x,y,z;
}请问如何让此结构的实例使用[]运算符啊要求
Vector v1;
v1[0]=x;
v1[1]=y;
v2[2]=z;
{
private double x,y,z;
}请问如何让此结构的实例使用[]运算符啊要求
Vector v1;
v1[0]=x;
v1[1]=y;
v2[2]=z;
解决方案 »
- 求助!关于回调函数中ref byte 转换成 byte[]的问题
- 请问,FileStream写数据,报错?
- C#如何在任务栏上增加类似于360软件小助手的按钮
- 在DataGridView中,是不是不能用CellValidating事件来验证新行啊?
- C#怎么运行一个.bat文件
- 请问MyBase.SmsQueue 的命名空间是什么?
- 求助:C#编写程序集在VB进行引用,生成安装程序后,运行报错!谢谢!!
- 请教几个初级问题
- 请问有什么好的算法:我要在form上添加n个label?
- 请大虾教小弟一招
- 去除WinForm中DataGridView数字列后面的零
- VB中的AddressOf在C#中如何描述呢
get{
...
return ....
}
set{
...
}
}
struct MyStruct
{
private Int32[] arr;
public MyStruct(Int32 i)
{
arr = new Int32[i];
}
public Int32 this[Int32 index]
{
get {
if (index > 0 && index < arr.Length)
return arr[index];
else
throw new Exception("out of range");
}
}
}
public class Program
{
static void Main(string[] args)
{ MyStruct myStruct = new MyStruct(10);
Console.WriteLine(myStruct[5]);
}
}