G
Guest
Hi,
I'm Roby E Martins, VC, VB, C# NET , ASP NET and JAVA developer.
I'm trying to create my on variable in C# ( Roby.Integer ).
I create a struct with operator to receive and send the value.
But I have a doubt. Receiving a value in the struct will call the
implict operator INT to Roby.Integer and then I'm must create a new
Roby.Integer.
I don't want to create new instances every time I send a new value to
my variable ( for best performance).
So, How can I receive the values and just changing the value in the
memory, without sending my variable to a new instance all the time?
namespace Roby
{
public struct Integer
{
//Every thing will be stored here
private int Value;
public static implicit operator Roby.Integer( int Value )
{
//Receive a int variable
// THIS IS NOT GOOD, BUT IT LOOKS LIKE IS THE ONLY WAY
return new Roby.Integer( Value );
}
public static implicit operator int( Roby.Integer Value )
{
//Sending the value to a int variable
return Value.Value;
}
}
}
I'm Roby E Martins, VC, VB, C# NET , ASP NET and JAVA developer.
I'm trying to create my on variable in C# ( Roby.Integer ).
I create a struct with operator to receive and send the value.
But I have a doubt. Receiving a value in the struct will call the
implict operator INT to Roby.Integer and then I'm must create a new
Roby.Integer.
I don't want to create new instances every time I send a new value to
my variable ( for best performance).
So, How can I receive the values and just changing the value in the
memory, without sending my variable to a new instance all the time?
namespace Roby
{
public struct Integer
{
//Every thing will be stored here
private int Value;
public static implicit operator Roby.Integer( int Value )
{
//Receive a int variable
// THIS IS NOT GOOD, BUT IT LOOKS LIKE IS THE ONLY WAY
return new Roby.Integer( Value );
}
public static implicit operator int( Roby.Integer Value )
{
//Sending the value to a int variable
return Value.Value;
}
}
}