I have created the following class. However, I cannot get past the error:
Must declare a body becase it is not marked abstract, extern or partial
The classe is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.CompilerServices;
namespace VDSORDAL
{
public abstract class ObjectComparer<T> : IComparer<T>
{
public ObjectComparer(string compareField, string direction);
private string compareField;
public string CompareField
{
get { return compareField; }
set { compareField = value; }
}
public string Direction
{
get { return compareField; }
set { compareField = value;}
}
public abstract int Compare(T x, T y);
}
}
Can someone point out the error in my ways and also give me a brief explanation as to what I am doing wrong and why it is throwing this error?
You have declared the constructor without a body:
public ObjectComparer(string compareField, string direction);
If you don't want the constructor to do anything, you can still put an empty body ({ }
) there.
As a side note, it doesn't make sense to have an abstract class with a public constructor -- the constructor should be protected, because the constructor can only be "called" by classes deriving from it anyway.
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