I'm having trouble using a struct. Why doesn't this work: -
The line "Changed.Skip = true; is rejected with messages: -
IDE1007 The name 'Changed' does not exist in the current context
IDE1007 The name 'Changed.Skip' does not exist in the current context
In researching this I found this site where I replaced their example of struct with mine by posting this code: -
This worked perfectly, producing the expected result
True
False
I have tried moving my definition of Changes to match this code structure, first to follow the the class containing Changes Changed = new Changes();, and then to the end of the object where it follows
In all cases I get the two IDE1007 messages from the 2nd of these statements, but there is no error on the first. If I write "Changed." there is no Intellisense list.
C#:
Changes Changed = new Changes();
Changed.Skip = true;
struct Changes
{
public bool Skip;
public bool EMPNO;
}
IDE1007 The name 'Changed' does not exist in the current context
IDE1007 The name 'Changed.Skip' does not exist in the current context
In researching this I found this site where I replaced their example of struct with mine by posting this code: -
C#:
using System;
public class Program
{
public static void Main()
{
Changes Changed = new Changes();
Changed.Skip = true;
Console.WriteLine(Changed.Skip);
Console.WriteLine(Changed.EMPNO);
}
}
struct Changes
{
public bool Skip;
public bool EMPNO;
}
True
False
I have tried moving my definition of Changes to match this code structure, first to follow the the class containing Changes Changed = new Changes();, and then to the end of the object where it follows
C#:
namespace MyJSv
{
}
C#:
Changes Changed = new Changes();
Changed.Skip = true;