Hi all,
I've got a MyList class that implements the IList<string>
interface. I can do all the IList-specific methods, but when I try to
do the ICollection ones, it says
"Error: 'Form1.MyList' does not implement interface member
'System.Collections.Generic.ICollection<string>.Ad d(string)'.
'MyList.Add(string)' is either static, not public, or has the wrong
return type."
Here's my Add method (list is the private member that holds the list):
public int Add(string s) {
list.addItem(s);
return list.getCount() - 1; // new item goes at end of
list
}
The help file says that Add takes an object of the type of the IList
(or ICollection), and returns an int (specifically, the position at
which the new item was added). Why does it say it's 'static, not
public, or has the wrong return type' when it's NOT static, it IS
public, and it DOES have the right return type?
Thanks,
Johon 1 1713
Never mind, the return type should be void. I found out by changing
the return type until it stopped complaining.
- John
jjsav...@gmail.com wrote:
Hi all,
I've got a MyList class that implements the IList<string>
interface. I can do all the IList-specific methods, but when I try to
do the ICollection ones, it says
"Error: 'Form1.MyList' does not implement interface member
'System.Collections.Generic.ICollection<string>.Ad d(string)'.
'MyList.Add(string)' is either static, not public, or has the wrong
return type."
Here's my Add method (list is the private member that holds the list):
public int Add(string s) {
list.addItem(s);
return list.getCount() - 1; // new item goes at end of
list
}
The help file says that Add takes an object of the type of the IList
(or ICollection), and returns an int (specifically, the position at
which the new item was added). Why does it say it's 'static, not
public, or has the wrong return type' when it's NOT static, it IS
public, and it DOES have the right return type?
Thanks,
Johon
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: CGuy |
last post by:
URGENT HELP REQUIRED FROM GURUS
Hi,
I have a custom object that implements ICollection and IListSource. This
object has also an enumerator defined for it which implements IEnumerator
and...
|
by: Chris |
last post by:
Hi,
the specs for System.Array are :
public abstract class Array : ICloneable, IList, ICollection,
IEnumerable
but I can't use any of the functions presented by IList in my code
...
|
by: Paul |
last post by:
Hi all,
I'm trying to implement IList and keep getting an error when trying to
implement GetEnumerator().
My class has a List<String> and I've been using its methods as return
types for IList,...
|
by: Lucian Wischik |
last post by:
Does ReadOnlyCollection<T> really implement IList<T>, like it claims
to do? ...
When I right-click on ReadOnlyCollection and look at its definition,
it says this:
public class...
|
by: nicolas.rolland |
last post by:
Would anyone know the reson why IList<Tdoes not implements IList ??
This results in strange behaviours, like
typeof(IList).IsAssignableFrom(typeof(List<string>)) --true...
|
by: BillG |
last post by:
I have a List collection object that I need to assign to a property that is
expecting a IEnumerable. How do I do that?
Thanks
Bill
|
by: Dansk |
last post by:
Hi all,
Can I assume that when I loop throw a Collection, List, IList,
ICollection, ... by using foreach, I first get the element of index 0,
then index 2, and so on until the last one ?
...
|
by: Tony |
last post by:
Hello!
According to the documentation we have the following
interface IList : ICollection, IEnumerable
{
I can understand all the methods in this IList
}
interface ICollection : IEnumerable...
|
by: Tony Johansson |
last post by:
Hello!
The Array class implements these interfaces IClonable, IList, ICollection
and IEnumerable.
Note only interfaces are inherited and no classes so these interfaces will
be implemented in...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |