Hey,
I was just testing/learning with classes and i'm stuck at how to instantiate the class.
I've spent few days trying get myself out of this mess but i don't think i'm getting anywhere.

The picture below shows where I'm stuck at.
The sln file is attached below for reference if needed to.
Please help.
Thanks.

Here are the classes in the project.
I paste it here so that it is easier to see.
Thanks.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace TestClass
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestClass
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            IOHandler.InitializeIOData();

            IOList.X100_On();

            if (IOList.X100)
                MessageBox.Show("Hello");
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestClass
{
    public class IOHandler
    {
        public static InputData[] InputCards;
        public class InputData
        {
            public int intCardNo;
            public int intStartingPortNo;
            public string[] strModule = new string[16];
            public string[] strBitName = new string[16];
            public bool[] byteReadBit = new bool[16];

            public InputData()
            {
                int intIndex;

                for (intIndex = 0; intIndex < 16; intIndex++)
                {
                    strBitName[intIndex] = "";
                    strModule[intIndex] = "";
                    byteReadBit[intIndex] = false;
                }
            }
        }

        public static void InitializeIOData()
        {
            int intIndex;
            int CurrentPhysicalCardNo;
            int CurrentVirtualCardNo;
            int CurrentVirtualPortNo;

            InputCards = new InputData[5];
            for (intIndex = 0; intIndex < 5; intIndex++)
            {
                if (InputCards[intIndex] == null)
                {
                    InputCards[intIndex] = new InputData();
                    InputCards[intIndex].intCardNo = 0;
                    InputCards[intIndex].intStartingPortNo = 0;
                }
            }

        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestClass
{
    class HardwareSettings
    {
    }

    public class IOList
    {
        //Read Input Status
        public static bool X100 = IOHandler.InputCards[0].byteReadBit[0];
        public static bool X101 = IOHandler.InputCards[0].byteReadBit[1];
        public static bool X102 = IOHandler.InputCards[0].byteReadBit[2];
        public static bool X103 = IOHandler.InputCards[0].byteReadBit[3];

        public static void X100_On() {IOHandler.InputCards[0].byteReadBit[0] = true;}
        public static void X101_On() { IOHandler.InputCards[0].byteReadBit[1] = true; }
        public static void X102_On() { IOHandler.InputCards[0].byteReadBit[2] = true; }
        public static void X103_On() { IOHandler.InputCards[0].byteReadBit[3] = true; }
    }
}
This article has been dead for over six months. Start a new discussion instead.