TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
onez
NA
73
0
Get & Set Indexer
Nov 29 2004 2:45 AM
How can I both get and set a value in an object in my indexer? DataIdxer_Instance[3].Accum += 123000; Error - cannot modify the return value of ...DataIdxer.this[int] Because it is NOT a variable. public class DataIdxer { protected ArrayList Datas = new ArrayList(); public DataObj this[int idx] { get { if (idx > -1 && idx < Datas.Count) { return ((DataObj)Datas[idx]); } else { throw new InvalidOperationException("[Data indexer get item] index out of range"); } } set { if (idx > -1 && idx < Datas.Count) { Datas[idx] = value; } else if (idx == Datas.Count) { Datas.Add(value); } else { throw new InvalidOperationException("[Datas indexer set item outofrange]"); } } } } public struct DataObj { public Int64 Accum; public DataObj(int D) { Accum = D; } }
Reply
Answers (
2
)
How to access my VB COM into C#?
Oracle