.NETGURU
How to define multiple indexers for single class or struct (that is two or more arrays)
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngcs' list.


edp
-- Moved from [aspngdatagridrepeaterdatalist] to [aspngcs] by Tim <Click here to reveal e-mail address> --

To define an indexer to a struct or class we do the following :

public struct MyStruct
{
public string []data;
public string this[int index]
{
get {return data[index];}
set {data[index] = value;}
}

public void click(Object sender, EventArgs e)
{
MyStruct ms = new MyStruct();
ms.data = new string[5];
ms[0] = "Hello";
........
}

However, what happens if I want to define two arrays in the structure and class and want to access it ??

that is something like this :

public struct MyStruct
{
public string []data1;
public string []data2;
}

Can someone help ??

CHEERS ALL !!

Sum Pun

Reply to this message...
 
    
Steve Mark
Implement the indexer in the class containing the struct:

public MyStruct this[int index]
{
    get {return structs[index];}
}

[Original message clipped]

Reply to this message...
 
 
System.EventArgs




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification