Why will my interface not import into my class? I just want to test some interfaces and need to have the one method extended into my class that implements my interface. This I thought would be simple but it is throwing me an error which I will list at the bottom. My method is public and it is throwing me and error. In fact I took the public keyword away and it is still throwing me an error.
Is there a short cut key to import all of the methods into a class.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FlowControl
{
public abstract class Grades : iBase, iFoot
{
public abstract void AddGrade(float grade);
public abstract void ComputeStatistics();
public void WriteGrades(string t)
{
}
public int AddTwo(int a, int b)
{
return 0;
}
void findYourScore() { }
}
public interface iBase
{
public void findYourScore();
}
public interface iFoot
{
}
}
But I get this error:
The modifier 'public' is not valid for this item
You can't specify access modifiers on interface methods, properties, events, or indexers. The interface itself is marked public, therefore all of its members are also implicitly public. However, you will have to specify an access modifier where you're implementing the method (unless you're writing an explicit interface member implementation).
For example:
public abstract class Grades : iBase, iFoot
{
...
public void findYourScore() { }
}
public interface iBase
{
void findYourScore();
}
Further Reading
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With