The file access modifier keyword
Let us create a console application using Visual Studio 2022 Community edition.
Now, add a new class as below:
namespace DotNet7File
{
public class FileTest
{
public void PrintDateCall()
{
Console.WriteLine("Printed from the FileTest.cs file");
}
}
}
namespace DotNet7File
{
public class FileTest
{
public void PrintDateCall()
{
Console.WriteLine("Printed from the AnotherFileTest.cs file");
}
}
}
namespace DotNet7File
{
file class FileTest
{
public void PrintDateCall()
{
Console.WriteLine("Printed from the AnotherFileTest.cs file");
}
}
}
using DotNet7File;
FileTest fileTest = new ();
fileTest.PrintDateCall();
namespace DotNet7File
{
file class FileTest
{
public void PrintDateCall()
{
Console.WriteLine("Printed from the AnotherFileTest.cs file");
}
}
public class ToCallExternally
{
public void CallTheFileLevelClass()
{
FileTest fileTest = new();
fileTest.PrintDateCall();
}
}
}
using DotNet7File;
ToCallExternally toCallExternally = new ();
toCallExternally.CallTheFileLevelClass();
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)