Based on web searches, I am having problems in my project with scope that many seem to have problems understanding.
I am working on an C# / WPF application where I would like to put much of my code in supporting classes. This would include parameters/variable, methods, etc. I am able to do this, but only by passing arguments for variables, class instances, etc. I would
like to define a few global variable and not have to repetitively pass these globally used arguments.
I have extensively reviewed MSDN, web, etc info on scope, but can not find info that provides guidance needed . I am sure it must be possible, but how? I obviously am not understanding what I read on Namespace; Class field, property, method, etc. scope.
Below is c# / WPF XAML code that illustrates what I hope to do.
Thank you.
<Window x:Class="Scope_Experiment.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
</Grid>
</Window>
namespace Scope_Experiment
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public Window mainwin;
public Class1 class1;
public MainWindow()
{
InitializeComponent();
mainwin = this;
class1 = new Class1();
}
}
}
namespace Scope_Experiment
{
class Class1
{
public String par1;
public Double par2;
public void method1()
{ /* Method Code */ }
}
}
namespace Scope_Experiment
{
class Class2
{
String C2par1 = class1.par1;
}
}
Jim Gunn