I want to compile and run some c# code, but it's not working due to the methods/classes not being found by referenced libraries. Even though i included the needed namespaces e.g. "using System.Collections.Generic;", they will be grey'd out and marked with "Using directive is unneccessary", even though my code requires it. As a result, compiling fails. What am I doing wrong?
using System.Collections.Generic;
namespace NetCoreExamples
{
class Program
{
static void Main(string[] args)
{
##some code##
}
private static async Task MainAsync(string[] args)
{
var type = Type.GetType(args[0]);
await (Task)type.GetMethod("RunAsync", BindingFlags.NonPublic | BindingFlags.Static)
.Invoke(null, new object[] {args.TakeLast(args.Length - 1).ToArray() });
}
}
}
On phrase "args.TakeLast(args.Length - 1)", "TakeLast" is underlined saying "string[] has no definition for TakeLast and no extension method was found that accepts the first argument as string[]. (Maybe missing using directive or assembly reference)".
To use System.Collections.Generic.IEnumerable, I discovered it's location:
Namespace: System.Collections.Generic
Assemblies: System.Runtime.dll, mscorlib.dll, netstandard.dll
But the "using System.Collections.Generic;" keeps being grey'd out, referencing the assemblies for the project did not change anything.
I am sure this is trivial, but I cannot seem to find out what I am doing wrong.