Solved

Function explanation c#

Posted on 2011-03-07
4
222 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
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
abstract class C# 1 31
linq, c# 8 26
Problem to Office 1 18
linq .concat equivalent with expression syntax 4 8
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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