Hi there. I have 2 apps: Class Library named ClLib, and Windows Form Application called ClLibApp.
In ClLib, I have a group of classes.
They are as shown below:
Singapore (parent class) - Nursery - Primary - Secondary
In ClLibApp, I need to add a reference from ClLib, so that I can use my application. The codings will be shown below.
Singapore
namespace ClLib.Singapore
{
public class SingaporeClass
{
public int subtract(int firstNum, int secNum)
{
return firstNum - secNum;
}
}
}
Nursery
namespace ClLib.Singapore.Nursery
{
public class ExchangeClass
{
public int subtractionNursery(int firstNum, int secNum)
{
return firstNum - secNum;
}
}
}
Primary
namespace ClLib.Singapore.Primary
{
public class ExchangeClass
{
public int subtractPrimary(int firstNum, int secNum)
{
return firstNum - secNum;
}
}
}
Secondary
namespace ClLib.Singapore.Secondary
{
public class ExchangeClass
{
public int subtractSecondary(int firstNum, int secNum)
{
return firstNum - secNum;
}
}
}
I do not want to put the methods all in the same class, meaning that I will want to have 3 different subclasses instead of having only 1 sub class to contain all the methods.
So in my ClLibApp, I create a button, and needs to have a directive that allows me to show the following:
using ClLib.Singapore; using ClLib.Singapore.Nursery; using ClLib.Singapore.Primary; using ClLib.Singapore.Secondary;
Take for instance, I have created a button called btnExchange, and it will show the answers for different methods. I would like to create it in a way somehow like this:
private void btnExchange_Click(object sender, EventArgs e)
{
ExchangeClass ExchClass = new ExchangeClass();
string answer = ExchClass.subtract(99,88).ToString();
MessageBox.Show(answer);
}
In the second line, I want to be able to use
string answer = Exch.subtractNursery(100,694).ToString();
string answer = Exch.subtractPrimary(8484,38).ToString();
string answer = Exch.subtractSecondary(39, 764).ToString();
I need guidance on this, and I have been trying to solve this for a few days but to no avail.