N
N
NameOf Var2018-04-19 13:16:51
C++ / C#
NameOf Var, 2018-04-19 13:16:51

Can interfaces in C# define operators?

Hey!
In E. Troelsen's book "The C# 5.0 Programming Language and the .NET 4.5 Platform" in Chapter 9 (Collections and Generics) in the very last paragraph (before "Summary") it says that interfaces can define operations). However, when creating a generic interface and defining an operator, an error is generated: Interfaces cannot contain operators.
5ad86c81312c2618582244.png
Is this an omission of Comrade Troelsen or translators? Or am I just misunderstanding the content of the paragraph?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Yudakov, 2018-04-19
@AlexanderYudakov

In this case:
"Operation" != "Operator"
"Operation" == "Method"
It is curious what is written there in the original. If something other than "methods", the author is a fat minus. And if all the same "methods", then a bold minus is already for the translator.
PS Judging by the documentation, the task is not solved:
https://docs.microsoft.com/en-us/dotnet/csharp/pro...
PPS Exactly, it is not solved:

An interface can't contain constants, fields, operators , instance constructors, finalizers, or types.
https://docs.microsoft.com/en-us/dotnet/csharp/pro...
In general, the author of the book drove away.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question