B
bobby
hi,
I came across this code which is struct Cycle and in 13 line there is
something (public int Value) that I do not understand what it is.
Is it a method or a variable?
Thanks for the help
Here is the code
struct Cycle
{
// Private fields
int _val, _min, _max;
// Constructor
public Cycle(int min, int max)
{
_val = min;
_min = min;
_max = max;
}
public int Value
{
get { return _val; }
set
{
if (value > _max)
_val = _min;
else
{
if (value < _min)
_val = _max;
else
_val = value;
}
}
}
public override string ToString()
{
return Value.ToString();
}
public int ToInteger()
{
return Value;
}
// Operators (new in .NET 2.0)
public static Cycle operator +(Cycle arg1, int arg2)
{
arg1.Value += arg2;
return arg1;
}
public static Cycle operator -(Cycle arg1, int arg2)
{
arg1.Value -= arg2;
return arg1;
}
}
I came across this code which is struct Cycle and in 13 line there is
something (public int Value) that I do not understand what it is.
Is it a method or a variable?
Thanks for the help
Here is the code
struct Cycle
{
// Private fields
int _val, _min, _max;
// Constructor
public Cycle(int min, int max)
{
_val = min;
_min = min;
_max = max;
}
public int Value
{
get { return _val; }
set
{
if (value > _max)
_val = _min;
else
{
if (value < _min)
_val = _max;
else
_val = value;
}
}
}
public override string ToString()
{
return Value.ToString();
}
public int ToInteger()
{
return Value;
}
// Operators (new in .NET 2.0)
public static Cycle operator +(Cycle arg1, int arg2)
{
arg1.Value += arg2;
return arg1;
}
public static Cycle operator -(Cycle arg1, int arg2)
{
arg1.Value -= arg2;
return arg1;
}
}