September 8, 2024

Our first class

Not just our first class, but a first namespace also (other than HogHeaven). We can pick namespace names out of a hat, but if we pick one like "System" that is already in use, we could get into trouble -- but not necessarily as long as we don't define classes that clash with existing classes.
using System;

namespace Example
{
    public class Wally
    {
        public static void chat ( string msg )
        {
            Console.WriteLine ( msg );
        }
    }
}

namespace HogHeaven
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Example.Wally.chat ( "Kilroy is here !!" );
        }
    }
}

// THE END
This code doesn't do anything different than our previous example; it just gets to the same place in different ways. You may find it interesting to try different simple things like this and find out what you can get away with. If you read about something and think you understand it, try it out and see if you really do.
Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org