I need to know how to use the command line to compile and run C# from the command line but I cannot figure out how to correctly use a DLL I made. The DLL is a simple maths file the code inside is:
using System;
namespace SimpleMaths
{
public class Operations
{
public static int add(int a, int b)
{
return a + b;
}
public static int substract(int a, int b)
{
return a - b;
}
public static int multiply(int a, int b)
{
return a * b;
}
}
}
I successfully compiled it as a DLL file. Now I have a class called sum.cs, and in there I want to access the methods of this library, I did have a lot of messy code in there which was nowhere near right so I deleted it, here is what I have now:
using System;
public class sum
{
public static void Main()
{
//How can I access the methods in the SimpleMaths library???
}
}
Usually in Visual Studio I would add the DLL as a reference and then create objects which would give me access to the methods. I have searched on-line and the examples I have found are confusing me. Am I right in saying that you cannot create objects using the command line?
Any advice is appreciated.
You need to use /reference in the command line.
Also make sure to include the namespace in your .cs file.