A
A. Burch
I'm having trouble understanding why I can't reference a struct in a method
If I have the following which works. I need to pass a reference to a method
in the namespace simple namespace. I thought where the >---right here is-->
would be the place to put a SimpleStrut ss definition that could be
referenced anywhere in the namespace. How do I define a reference to
"SimpleStrut ss and just use ss in Main with the definition above it.
Thanks.......
using System;
namespace simple
{
struct SimpleStruct
{
private int xval;
public int X
{
get
{
return xval;
}
set
{
if (value < 100)
xval = value;
}
}
public void DisplayX()
{
Console.WriteLine("The stored value is: {0}", xval);
}
}
class simple
{
//-----right here------> SimpleStruct ss;
[STAThread]
static void Main(string[] args)
{
SimpleStruct ss = new SimpleStruct();
ss.X = 5;
ss.DisplayX();
}
}
}
If I have the following which works. I need to pass a reference to a method
in the namespace simple namespace. I thought where the >---right here is-->
would be the place to put a SimpleStrut ss definition that could be
referenced anywhere in the namespace. How do I define a reference to
"SimpleStrut ss and just use ss in Main with the definition above it.
Thanks.......
using System;
namespace simple
{
struct SimpleStruct
{
private int xval;
public int X
{
get
{
return xval;
}
set
{
if (value < 100)
xval = value;
}
}
public void DisplayX()
{
Console.WriteLine("The stored value is: {0}", xval);
}
}
class simple
{
//-----right here------> SimpleStruct ss;
[STAThread]
static void Main(string[] args)
{
SimpleStruct ss = new SimpleStruct();
ss.X = 5;
ss.DisplayX();
}
}
}