.NET Core is not enforcing class implements inherited interface [closed]
up vote
4
down vote
favorite
I'm seeking some guidance with the following issue.
I have an Interface A with a method A.DoSomething
I have another interface B with a method B.DoSomethingElse. B Inherits from A
I have a class C that inherits from interface B
interface A
{
void DoSomething();
}
interface B : A
{
void DoSomethingElse();
}
public class C : B
{
public void DoSomethingElse()
{
//do something else here
}
}
If I write the above code in .NET Standard I get a compile time error stating that class C must implement interface A. However if I write the same code in .NET Core I don't get any compile time error to enforce the implementation of interface A in class C.
I'm using .NET Core 2.1 with Visual Studio Enterprise 2017 version 15.8.9.
c# visual-studio .net-core
closed as off-topic by Rob♦ Nov 28 at 3:57
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Rob
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
4
down vote
favorite
I'm seeking some guidance with the following issue.
I have an Interface A with a method A.DoSomething
I have another interface B with a method B.DoSomethingElse. B Inherits from A
I have a class C that inherits from interface B
interface A
{
void DoSomething();
}
interface B : A
{
void DoSomethingElse();
}
public class C : B
{
public void DoSomethingElse()
{
//do something else here
}
}
If I write the above code in .NET Standard I get a compile time error stating that class C must implement interface A. However if I write the same code in .NET Core I don't get any compile time error to enforce the implementation of interface A in class C.
I'm using .NET Core 2.1 with Visual Studio Enterprise 2017 version 15.8.9.
c# visual-studio .net-core
closed as off-topic by Rob♦ Nov 28 at 3:57
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Rob
If this question can be reworded to fit the rules in the help center, please edit the question.
1
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
Nov 10 at 6:04
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the: A
but still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?
– Simply Ged
Nov 10 at 6:31
Ditto. Got compile error with the code you have shared. As @SimplyGed suggested, share your code on Github and we might be able to troubleshoot this further.
– dj79
Nov 11 at 7:50
It might have been a transient error with the C# compiler. I'm also getting the expected error after rebooting. Thank you all for your time.
– Danny Acosta
Nov 11 at 11:36
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I'm seeking some guidance with the following issue.
I have an Interface A with a method A.DoSomething
I have another interface B with a method B.DoSomethingElse. B Inherits from A
I have a class C that inherits from interface B
interface A
{
void DoSomething();
}
interface B : A
{
void DoSomethingElse();
}
public class C : B
{
public void DoSomethingElse()
{
//do something else here
}
}
If I write the above code in .NET Standard I get a compile time error stating that class C must implement interface A. However if I write the same code in .NET Core I don't get any compile time error to enforce the implementation of interface A in class C.
I'm using .NET Core 2.1 with Visual Studio Enterprise 2017 version 15.8.9.
c# visual-studio .net-core
I'm seeking some guidance with the following issue.
I have an Interface A with a method A.DoSomething
I have another interface B with a method B.DoSomethingElse. B Inherits from A
I have a class C that inherits from interface B
interface A
{
void DoSomething();
}
interface B : A
{
void DoSomethingElse();
}
public class C : B
{
public void DoSomethingElse()
{
//do something else here
}
}
If I write the above code in .NET Standard I get a compile time error stating that class C must implement interface A. However if I write the same code in .NET Core I don't get any compile time error to enforce the implementation of interface A in class C.
I'm using .NET Core 2.1 with Visual Studio Enterprise 2017 version 15.8.9.
c# visual-studio .net-core
c# visual-studio .net-core
edited Nov 10 at 5:12
user2864740
43.4k669146
43.4k669146
asked Nov 10 at 5:07
Danny Acosta
211
211
closed as off-topic by Rob♦ Nov 28 at 3:57
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Rob
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by Rob♦ Nov 28 at 3:57
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Rob
If this question can be reworded to fit the rules in the help center, please edit the question.
1
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
Nov 10 at 6:04
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the: A
but still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?
– Simply Ged
Nov 10 at 6:31
Ditto. Got compile error with the code you have shared. As @SimplyGed suggested, share your code on Github and we might be able to troubleshoot this further.
– dj79
Nov 11 at 7:50
It might have been a transient error with the C# compiler. I'm also getting the expected error after rebooting. Thank you all for your time.
– Danny Acosta
Nov 11 at 11:36
add a comment |
1
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
Nov 10 at 6:04
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the: A
but still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?
– Simply Ged
Nov 10 at 6:31
Ditto. Got compile error with the code you have shared. As @SimplyGed suggested, share your code on Github and we might be able to troubleshoot this further.
– dj79
Nov 11 at 7:50
It might have been a transient error with the C# compiler. I'm also getting the expected error after rebooting. Thank you all for your time.
– Danny Acosta
Nov 11 at 11:36
1
1
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
Nov 10 at 6:04
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
Nov 10 at 6:04
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the
: A
but still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?– Simply Ged
Nov 10 at 6:31
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the
: A
but still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?– Simply Ged
Nov 10 at 6:31
Ditto. Got compile error with the code you have shared. As @SimplyGed suggested, share your code on Github and we might be able to troubleshoot this further.
– dj79
Nov 11 at 7:50
Ditto. Got compile error with the code you have shared. As @SimplyGed suggested, share your code on Github and we might be able to troubleshoot this further.
– dj79
Nov 11 at 7:50
It might have been a transient error with the C# compiler. I'm also getting the expected error after rebooting. Thank you all for your time.
– Danny Acosta
Nov 11 at 11:36
It might have been a transient error with the C# compiler. I'm also getting the expected error after rebooting. Thank you all for your time.
– Danny Acosta
Nov 11 at 11:36
add a comment |
1 Answer
1
active
oldest
votes
up vote
-2
down vote
this is the correct way to implement the interfaces
public class C : B {
public void DoSomething(){
//do something
}
public void DoSomethingElse()
{
//do something else here
}}
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
Nov 10 at 7:04
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
-2
down vote
this is the correct way to implement the interfaces
public class C : B {
public void DoSomething(){
//do something
}
public void DoSomethingElse()
{
//do something else here
}}
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
Nov 10 at 7:04
add a comment |
up vote
-2
down vote
this is the correct way to implement the interfaces
public class C : B {
public void DoSomething(){
//do something
}
public void DoSomethingElse()
{
//do something else here
}}
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
Nov 10 at 7:04
add a comment |
up vote
-2
down vote
up vote
-2
down vote
this is the correct way to implement the interfaces
public class C : B {
public void DoSomething(){
//do something
}
public void DoSomethingElse()
{
//do something else here
}}
this is the correct way to implement the interfaces
public class C : B {
public void DoSomething(){
//do something
}
public void DoSomethingElse()
{
//do something else here
}}
answered Nov 10 at 6:47
J.Oliver
1
1
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
Nov 10 at 7:04
add a comment |
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
Nov 10 at 7:04
4
4
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
Nov 10 at 7:04
Welcome to Stack Overflow. Although your answer is correct, it does not answer the question the user has asked. Please take some time to read How to Answer to understand what is required for a good quality answer.
– Simply Ged
Nov 10 at 7:04
add a comment |
1
Just tried your code (same .NET core version and VS version) and I get the expected compile error.
– Klaus Gütter
Nov 10 at 6:04
I've tried it as well and get the same error in .NET Core, .NET Standard and .NET Framework. I know it sounds silly but are you sure the inheritance is setup correctly in the .NET Core code? (It's easy to miss off the
: A
but still think it's there...we've all done it at one time :-) ) Could you share your code in GitHub so we can see the full projects please?– Simply Ged
Nov 10 at 6:31
Ditto. Got compile error with the code you have shared. As @SimplyGed suggested, share your code on Github and we might be able to troubleshoot this further.
– dj79
Nov 11 at 7:50
It might have been a transient error with the C# compiler. I'm also getting the expected error after rebooting. Thank you all for your time.
– Danny Acosta
Nov 11 at 11:36