C
Chris LaJoie
I would like to be able to set my struct equal to null in a way similar to
this example:
struct TestStruct {
public int x;
}
....[other stuff]...
public void Main() {
TestStruct testvar;
testvar.x = 4;
if(testvar.x == 4) {
testvar = null;
}
...[more code]...
}
is this possible using operators? I was thinking something like this:
struct TestStruct {
public int x;
public static bool operator null(TestStruct t) {
return (t.x == 0);
}
}
that struct won't compile, but i thought it might help you to understand my
problem, and how I think it might be solved.
I know that this would be easy to do by simply using a class instead of a
struct, but I would like to be able to use other operators as well. Any
help is appreciated. Thanks,
Chris LaJoie
this example:
struct TestStruct {
public int x;
}
....[other stuff]...
public void Main() {
TestStruct testvar;
testvar.x = 4;
if(testvar.x == 4) {
testvar = null;
}
...[more code]...
}
is this possible using operators? I was thinking something like this:
struct TestStruct {
public int x;
public static bool operator null(TestStruct t) {
return (t.x == 0);
}
}
that struct won't compile, but i thought it might help you to understand my
problem, and how I think it might be solved.
I know that this would be easy to do by simply using a class instead of a
struct, but I would like to be able to use other operators as well. Any
help is appreciated. Thanks,
Chris LaJoie