How to call a static method form interface in a generic class.
So I have a class as bellow.
and then a second generic class.
but I am getting the error.
https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0704?f1url=%3FappId%3Droslyn%26k%3Dk(CS0704)
The problem is I can't directly call the type from a generic. Is there anyway to do this, or am I trying to do something C# just can't do?
7 Replies
Can't you do
ISetup<T, P>.Setup(holder, setupArg)
CS0176 Member 'ISetup<TYPE, ARGS>.Setup(TYPE, ARGS)' cannot be accessed with an instance reference; qualify it with a type name instead
CS0426 The type name 'Setup' does not exist in the type 'ISetup<TYPE, ARGS>'
This works on my end, what version of C# and dotnet are you using?
.NET Framework
Very well could be. The fact Unity hasn't updated to .net 6.0 is the bain of my existence on many levels.
Hmm, I think it should work from C# 8
Lett me test on Unity real quick
It does compile
Weird, let me check on a clean project, maybe something else causing it to not work.
Figured it out, the above does work(and corrected from before). I had a new before the call in the actual code which was causing the error.