What is the use of Interface
I'm wondering what is the difference between referencing "void" directly from another file and calling it with "Interface"? I'm a newbie to C#, and a lot of cross-file code calls are used directly with a new definition of that file name, such as "public Player_Data PD"
13 Replies
polymorphism
Can you clarify exactly what the question is here? Are you asking how to properly call methods from another file, or do you want to know what the
interface
keyword is used for?they are saying they have static methods
I assume they were told to try interfaces
interfaces are for when a function has to do different things depending on the context
kind of
you're fine with regular methods
you don't need interfaces, unless you know you need them
I don't think thats what they are saying at all.
used directly with a new definition of that file name,sounds more like
new Example().MethodName();
to me, with a potential variable in there tooyou can do 99% of things without them
so @CloudFox can you clarify?
yeah you're right. not static, just methods
I don't know what the interface does
it lets you call a method without referring to it directly
its a way to declare a contract that implementing classes must adhere to. This allows you to call methods without knowing the concrete implementation.
and then pass an object that has a method you want to get called
example:
I seem to understand something, I'll give it a try, thank you very much!