What i would like to be able to do is control the assignment of two objects. So if my class looked like this in the case of a string (very crude but just and example)
public class fixLen
{
public int len;
public string str;
public fixLen(string str, int len)
{
this.str = str;
this.len = len;
}
}
Then in my main class i do this;
fixLen str1 as new fixLen("abc", 3);
fixLen str2 as new fixLen("wxyz", 4);
str1 = str2
When str2 is assigned to str1 i would like to be able to query the len property of each object and perform the assignment. In this case i would like the str1.str property to end up with a value of "wxy" truncating "wxyz" to 3 characters (str1.len). I have tried to implement this with the "operator" program element but it doesn't appear to allow me to query both the source and target objects. A key element of this functionality is it has to be implemented in the class. I do not want to have any other syntax in my main class other than;
str1 = str2
I guess in it's simplest terms i would like to create another atomic type, like int, float or string.
In the case of a number;
public class fixNum
{
public int len;
public string val;
public fixLen(int val, int len)
{
this.val= val;
this.len = len;
}
}
Then in my main class;
fixNum num1 as new fixNum(0, 2)
fixnum num2 as new fixNum(999, 3)
num1 = num2 + 1
So num1 would end up with a value of 99.