Hi All,
I am coming from C++ world and working on some C# code. Currently working on a class with an ArrayList data member and would like to control which methods/behaviours get exposed to the client of this class.
One of the functions in this class takes an index as input, checks to make sure the index is not out of bounds and then returns the element if the index is valid.
I am getting a compiler error message (not all code paths return a value) and would like some hep into figuring how to resolve it.
Please advise if there is a better way of implementing this code in C#, or there is a c# way of implementing this function.
Thanks in advance.
namespace TrackStudents
{
class EnrolledClass
{
//code somewhere before the getElement method in a class...
ArrayList myArrayList = new ArrayList();
//more methods here......
public string getElement( int index )
{
if ( ! (index < MIN) || (index >= myArrayList.Count) )
{
return myArrayList[index];
}
}
}
}/*END: NAMESPACE*/