Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Function explanation c#

Posted on 2011-03-07
4
Medium Priority
?
226 Views
Last Modified: 2012-05-11
Hello all,

I am using a class that i downloaded from: http://www.codeproject.com/KB/recipes/K-Mean_Clustering.aspx

And in the class Kmeans. They say that this function:

/// <summary>
            /// Returns the one dimensional array data located at the index
            /// </summary>
            public virtual double [] this[int Index]
            {
                  get
                  {
                        //return the Neuron at IList[Index]
                        return (double[])this.List[Index];      
                  }    
            }
I don't understand how to get the list. it's the first time that i see this in c# i am really new. Thank you.
0
Comment
Question by:dadadude
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 35063043
In looking at that definition, what I see is the class KMeans is a class which implements IEnumerable, meaning it can be indexed. Think of it basically as an array itself. This "array" holds lists of doubles in each of its slots. When you have an instance of this class:

    KMeans instance = new KMeans();

you can treat it like an array and index it:

    double[] aList = instance[0];
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35063048
Actually, I made an assumption that it implements IEnumerable--that may or may not be accurate. The concept of treating it like an array still applies though.
0
 
LVL 1

Expert Comment

by:lalitgada
ID: 35067886
crate an object of Ilist
and return that object.
0
 

Author Comment

by:dadadude
ID: 35068169
yes Thank you, Kaufmed. Actually i managed to understand it. thank you for your explanation. It was just a list of double. But the way that it is written is new for me.

Thanks again.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question