Function from .cs file calling function from a different .cs file
What I am trying to do (in brief terms):
I have a function in a .cs file (A) that needs to access a function in a different .cs file (B). Based on certain calculations, (B) will alter (A) variables.
The problem:
I keep getting the following WARNINGs:
warning CS0649: Field 'programX.MainWindow.tCodes' is never assigned to, and will always have its default value null
warning CS0649: Field 'programX.TriggerCodes.function_MainWindow' is never assigned to, and will always have its default value null
Possibly needed details:
OS: Windows 7 64-bit
Compiler: MS Visual Studio 2010 Ultimate
Language: C# (WPF)
Framework: 4.0
And finally, a sample piece of code:
In "MainWindow.xaml.cs":
Code:
namespace programX
{
public partial class MainWindow : Window
{
public TriggerCodes tCodes;
public MainWindow()
{
InitializeComponent();
}
protected internal void doSomething()
{
if (tCodes.triggerCodeFound("Hello World"))
return;
Console.WriteLine("Didn't find it");
}
public void sayHello(string message)
{
StringBuilder msg = new StringBuilder();
msg.Append("Hello ");
msg.Append(message);
// *should* write "Hello Silly Person!"
Console.WriteLine(msg.ToString());
}
}
}
In "TriggerCodes.cs":
Code:
namespace programX
{
public partial class TriggerCodes
{
public MainWindow function_MainWindow;
public bool triggerCodeFound(String theData)
{
if ((theData.IndexOf("World") > (-1)))
{
this.function_MainWindow.sayHello("Silly Person!");
return (true);
}
return (false);
}
}
}
I am a C/C++ coder by trade, and just learning C#. In C/C++, this is a rather simple concept for me to grasp, however, C# is kicking my arse and laughing all the way.
Any help to avenge this temporary nemesis would be awesome.
Thanks!