Discussion:
method must have a return type
(too old to reply)
mp
2016-12-17 19:57:17 UTC
Permalink
i don't understand why i'm getting this compiler msg

interface IBuildingComponent
{
...
void WriteToCadDrawing();
void ReadFromCadDrawing();
}

interface ICastStone : IBuildingComponent
{...
new void WriteToCadDrawing();
new void ReadFromCadDrawing();
}

interface ICastStone : IBuildingComponent
{ ...
new void WriteToCadDrawing();
new void ReadFromCadDrawing();
}
class CastStone : ICastStone
{ ...
public virtual void WriteToCadDrawing() { }//no warning
public virtual void ReadFromCadDrawing() { }//method must have a
return type
}

I suspect the compiler is getting confused by my many edits and rewrites
as I continue to develop the overall plan of the program

i have 38 other errors i'm working thru so i assume somewhere in that is
something that is making this appear wrong, but to me they look identical

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Arne Vajhøj
2016-12-17 22:09:01 UTC
Permalink
Post by mp
i don't understand why i'm getting this compiler msg
interface IBuildingComponent
{
...
void WriteToCadDrawing();
void ReadFromCadDrawing();
}
interface ICastStone : IBuildingComponent
{...
new void WriteToCadDrawing();
new void ReadFromCadDrawing();
}
What is this supposed to do?

Since these methods are in IBuildingComponent then you
don't need them again.
Post by mp
interface ICastStone : IBuildingComponent
{ ...
new void WriteToCadDrawing();
new void ReadFromCadDrawing();
}
And now you repeat the interface??
Post by mp
class CastStone : ICastStone
{ ...
public virtual void WriteToCadDrawing() { }//no warning
public virtual void ReadFromCadDrawing() { }//method must have a
return type
}
I suspect the compiler is getting confused by my many edits and rewrites
as I continue to develop the overall plan of the program
i have 38 other errors i'm working thru so i assume somewhere in that is
something that is making this appear wrong, but to me they look identical
Start with the above.

Arne
mp
2016-12-18 00:17:38 UTC
Permalink
Post by Arne Vajhøj
Post by mp
i don't understand why i'm getting this compiler msg
interface IBuildingComponent
interface ICastStone : IBuildingComponent
What is this supposed to do?
Since these methods are in IBuildingComponent then you
don't need them again.
Start with the above.
Arne
obviously i'm new to c# interfaces and programming so i'm totally
stumbling in dark learning by reading the help files, online etc, and
especially you guys' indispensable and much appreciated help :-)

it sounds like you're saying that if a class inherits from an interface
it has to contain all the interface definitions but if an interface
inherits from an interface you don't have to repeat them is that right?



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Arne Vajhøj
2016-12-18 00:29:11 UTC
Permalink
Post by mp
Post by Arne Vajhøj
Post by mp
i don't understand why i'm getting this compiler msg
interface IBuildingComponent
interface ICastStone : IBuildingComponent
What is this supposed to do?
Since these methods are in IBuildingComponent then you
don't need them again.
Start with the above.
obviously i'm new to c# interfaces and programming so i'm totally
stumbling in dark learning by reading the help files, online etc, and
especially you guys' indispensable and much appreciated help :-)
it sounds like you're saying that if a class inherits from an interface
it has to contain all the interface definitions but if an interface
inherits from an interface you don't have to repeat them is that right?
Yes.

Arne
mp
2016-12-18 00:27:52 UTC
Permalink
Post by mp
i don't understand why i'm getting this compiler msg
class CastStone : ICastStone
{ ...
public virtual void WriteToCadDrawing() { }//no warning
public virtual void ReadFromCadDrawing() { }//method must have a
return type
}
ok this in interesting, per your other reply i remove the read and write
from ICastStone but still had the compiler error on that same line,
so i commented out that line and the error jumps to the previous line

public virtual void WriteToCadDrawing() { }//now warning appears here
// public virtual void ReadFromCadDrawing() { }//commented out this line

and if i comment out that line it jumps to the preceeding line

public double SectionArea {get;set;}//now error appears here
// public virtual void WriteToCadDrawing() { }//commented out
// public virtual void ReadFromCadDrawing() { }//commented out

ha finally found it!!!
the line *after* ReadFrom... was an internal method that i had failed to
assign a void value to...silly me


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Registered User
2016-12-18 19:13:29 UTC
Permalink
Post by mp
i don't understand why i'm getting this compiler msg
interface IBuildingComponent
{
...
void WriteToCadDrawing();
void ReadFromCadDrawing();
}
interface ICastStone : IBuildingComponent
{...
new void WriteToCadDrawing();
new void ReadFromCadDrawing();
}
interface ICastStone : IBuildingComponent
{ ...
new void WriteToCadDrawing();
new void ReadFromCadDrawing();
}
As Arne wrote there is no need to redeclare the methods.
Post by mp
class CastStone : ICastStone
{ ...
public virtual void WriteToCadDrawing() { }//no warning
public virtual void ReadFromCadDrawing() { }//method must have a
return type
}
You've already determined why the error was occuring. You ask good questions
which indicates you're trying to think things through. Good job!

Having the CastStone type 'know' about CAD drawing isn't the best of ideas. In
the future there may be other uses for these types which are not CAD-related.
There is also a possibility the CAD drawing may require different functionality
in the future. Separating the CAD functionality from the type simplifies the
type keeping it all about cast stone. CAD functionality can be included in a
derived type something like this:

// interface used specifically for CAD drawing
public interface ICadDrawing
{
void WriteToCadDrawing();
void ReadFromCadDrawing();
}

// derived type that knows about cast stone and CAD
public class CadCastStone : CastStone, ICadDrawing
{
public void WriteToCadDrawing() { ... }
public void ReadFromCadDrawing() { ... }
}
mp
2016-12-18 19:31:43 UTC
Permalink
Post by Registered User
Post by mp
i don't understand why i'm getting this compiler msg
interface IBuildingComponent
{
...
void WriteToCadDrawing();
void ReadFromCadDrawing();
}
interface ICastStone : IBuildingComponent
{...
new void WriteToCadDrawing();
new void ReadFromCadDrawing();
}
interface ICastStone : IBuildingComponent
{ ...
new void WriteToCadDrawing();
new void ReadFromCadDrawing();
}
As Arne wrote there is no need to redeclare the methods.
Post by mp
class CastStone : ICastStone
{ ...
public virtual void WriteToCadDrawing() { }//no warning
public virtual void ReadFromCadDrawing() { }//method must have a
return type
}
You've already determined why the error was occuring. You ask good questions
which indicates you're trying to think things through. Good job!
Having the CastStone type 'know' about CAD drawing isn't the best of ideas. In
the future there may be other uses for these types which are not CAD-related.
There is also a possibility the CAD drawing may require different functionality
in the future. Separating the CAD functionality from the type simplifies the
type keeping it all about cast stone. CAD functionality can be included in a
// interface used specifically for CAD drawing
public interface ICadDrawing
{
void WriteToCadDrawing();
void ReadFromCadDrawing();
}
// derived type that knows about cast stone and CAD
public class CadCastStone : CastStone, ICadDrawing
{
public void WriteToCadDrawing() { ... }
public void ReadFromCadDrawing() { ... }
}
perfect that's exactly what i've been thinking, I just now responded to
another of your posts about namespaces that starts down that road

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
mp
2016-12-19 13:41:53 UTC
Permalink
Post by Registered User
You've already determined why the error was occuring. You ask good questions
which indicates you're trying to think things through. Good job!
Having the CastStone type 'know' about CAD drawing isn't the best of ideas
CAD functionality can be included in a
// interface used specifically for CAD drawing
public interface ICadDrawing
{
void WriteToCadDrawing();
void ReadFromCadDrawing();
}
// derived type that knows about cast stone and CAD
public class CadCastStone : CastStone, ICadDrawing
{
public void WriteToCadDrawing() { ... }
public void ReadFromCadDrawing() { ... }
}
what i had so far was IView and IViews (List<Iview>)
then castStone had property .Views to contain it's potential for drawing
itself. then the view would have the ability to draw rather than the
caststone. don't know if that's sufficiently like what you suggest?
then i have ICadReader and ICadWriter that the view would use to draw itself

and a related question i'm mulling is a list of names requried by the
drawing activities, (in 'cad parlance' layername drawingname, sheetname,
vviewname, linetypename, blockname etc etc)
currently i have CadNames class to hold these properties which the view
would use to store and retrieve this required data...but don't know if
this is an optimal way to do this???? also not sure if i would need a
ICadNames interface or if a class is sufficient. I suppose if I started
with CadNames : ICadNames and then found later additional names i hadn't
thought of I could add CadNames:ICadnames, IMoreCadNames ???

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Continue reading on narkive:
Loading...