partial classes error

asdf

New member
Joined
Oct 25, 2016
Messages
1
Programming Experience
10+
Trying a partial class example from https://www.dotnetperls.com/partial
Getting error "The name 'A' does not exist in the current context."
Please help me get it to work.

This is in b.cs

C#:
class Program
{
    static void Main()
    {
        A.A1();
        A.A2();
    }
}

This is in A1.cs

C#:
using System;

partial class A
{
   public static void A1()
   {
      Console.WriteLine("A1");
   }
}

This is in A2.cs

C#:
using System;

partial class A
{
   public static void A2()
   {
      Console.WriteLine("A2");
   }
}

This is in csc.bat

c:\windows\microsoft.net\framework64\v3.5\csc b.cs
 
csc.exe will only compile what you tell it to. List all source files to be compiled, or all (*.cs). Command-line Building With csc.exe

I recommend you use a developer IDE, Microsoft has both full Visual Studio Community edition and Express editions for free, there is also SharpDevelop that I know of.
If you can't/won't use IDE it is favorable to write a project file (csproj) and compile with msbuild.exe, csc.exe can quickly get very hard to work with.
 
I recommend you use a developer IDE, Microsoft has both full Visual Studio Community edition and Express editions for free, there is also SharpDevelop that I know of.

And VS Code as well.
 
Back
Top Bottom