Saturday, April 26, 2025

C# OO - Namespaces - External Files

ExternalSource.cs

using System;
using System.Collections.Generic;
using System.Text;

namespace LearnCS
{
    class ExternalSource
    {
        public static void ExternalMethod() {
            Console.WriteLine("But, I am from External Method");
        }

        public static int x = 100;
    }
}

namespace DirectPrinter
{
    class DirectA
    {
        public static void DirectPrintA() {
            Console.WriteLine("Line from DirectPrintA Method, from DirectA Class");
        }
    }
    class DirectB
    {
        public static void DirectPrintB()
        {
            Console.WriteLine("Line from DirectPrintB Method, from DirectB Class");
        }
    }
}

Program.cs

using System;
using DirectPrinter;
//using DDPA = DirectPrinter;

namespace LearnCS
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("I am from Main File");

            ExternalSource.ExternalMethod();
            Console.WriteLine("Variable from External Source: " + ExternalSource.x);

            //Stuff from External Source

            DirectA.DirectPrintA();
            DirectB.DirectPrintB();

            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...