T
Todd Carnes
I'm teaching myself C# and am creating my first c# DLL. I can get it to
work, but not the way I want it to work.
In my DLL, I have the following...
namespace Carnesoft.Astro
{
public class Change
{
public static double toJulianDayNumber(double dDay, int iMonth, int
iYear)
{
// some code to do something
}
}
}
I've written some test code in another project to make sure that these
methods work as expected that looks like this...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Carnesoft.Astro;
namespace testJDN
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void btnGo_Click(object sender, EventArgs e)
{
int month, year;
double day, jdn;
month = Convert.ToInt32(tbMonth.Text);
day = Convert.ToDouble(tbDay.Text);
year = Convert.ToInt32(tbYear.Text);
jdn = Change.toJulianDayNumber(day, month, year);
lblResult.Text = Convert.ToString(jdn);
}
private void frmMain_Load(object sender, EventArgs e)
{
Change Change = new Change();
}
}
}
The code works as is, but my question is...
How do I write my DLL so that I don't have to create a Change object in the
frmMain_Load event?
Is this possible, or will I have to instantiate every class that I have in
my DLL before I will be able to use the methods contained within them?
Thank you for any pointers (or URLs) you may give me in advance.
Respectfully,
Todd
work, but not the way I want it to work.
In my DLL, I have the following...
namespace Carnesoft.Astro
{
public class Change
{
public static double toJulianDayNumber(double dDay, int iMonth, int
iYear)
{
// some code to do something
}
}
}
I've written some test code in another project to make sure that these
methods work as expected that looks like this...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Carnesoft.Astro;
namespace testJDN
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void btnGo_Click(object sender, EventArgs e)
{
int month, year;
double day, jdn;
month = Convert.ToInt32(tbMonth.Text);
day = Convert.ToDouble(tbDay.Text);
year = Convert.ToInt32(tbYear.Text);
jdn = Change.toJulianDayNumber(day, month, year);
lblResult.Text = Convert.ToString(jdn);
}
private void frmMain_Load(object sender, EventArgs e)
{
Change Change = new Change();
}
}
}
The code works as is, but my question is...
How do I write my DLL so that I don't have to create a Change object in the
frmMain_Load event?
Is this possible, or will I have to instantiate every class that I have in
my DLL before I will be able to use the methods contained within them?
Thank you for any pointers (or URLs) you may give me in advance.
Respectfully,
Todd