interface?!

  • Thread starter Thread starter nicol
  • Start date Start date
N

nicol

hi
i have a problem with interface plz help me
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
}
}
}
public interface Ishape
{
double masahat();
double mohit();
}
public class point : Ishape
{
private double radiuse;
public point()
{
}
public point(int radiuse_value)
{
Radiuse = radiuse_value;
}
public double Radiuse
{
get
{
return radiuse;
}
set
{
radiuse = value;
}
}
public override double masahat() //*******here has error*****
{
}
}
 
hi
i have a problem with interface plz help me
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
}
}
}
public interface Ishape
{
double masahat();
double mohit();
}
public class point : Ishape
{
private double radiuse;
public point()
{
}
public point(int radiuse_value)
{
Radiuse = radiuse_value;
}
public double Radiuse
{
get
{
return radiuse;
}
set
{
radiuse = value;
}
}
public override double masahat() //*******here has error*****
{
}
}

Because there's nothing to override, only to implement.
Write the method as

public double masahat()
{
}

and you're good.

btw:
if this is your actual code, then your next error message will be that
your class doesn't implement method "mohit" of the Ishape interface.
 
hi
i have a problem with interface plz help me
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
     class Program
     {
         static void Main(string[] args)
         {
         }
     }
}
public interface Ishape
{
     double masahat();
     double mohit();
}
public class point : Ishape
{
     private double radiuse;
     public point()
     {
     }
     public point(int radiuse_value)
     {
         Radiuse = radiuse_value;
     }
     public double  Radiuse
     {
         get
         {
             return radiuse;
         }
         set
         {
             radiuse = value;
         }
     }
     public override double masahat()  //*******here has error*****
     {
     }
}

Because there's nothing to override, only to implement.
Write the method as

public double masahat()
{

}

and you're good.

btw:
if this is your actual code, then your next error message will be that
your class doesn't implement method "mohit" of the Ishape interface.

thanks the error solved with your help . but i really don't know
where i must use override ?
 
nicol said:
thanks the error solved with your help . but i really don't know
where i must use override ?

Look at the word "override". That implies that there's an existing
implementation that you do NOT want to use in this case, that you want
to OVERRIDE.

Which means it is never going to apply to an interface, which is all
definition and no implementation (at least in the interface itself).
 
nicol said:
thanks the error solved with your help . but i really don't know
where i must use override ?

Whatever documentation you read that told you that such a thing as
"override" exists is likely to be where you will find details on how it
is used. What it didn't tell you is that you would use it for
implementing a method of an interface, because it isn't used for that.
 
Whatever documentation you read that told you that such a thing as
"override" exists is likely to be where you will find details on how it
is used. What it didn't tell you is that you would use it for
implementing a method of an interface, because it isn't used for that.

thanks
 
Back
Top