operator overloading "+" & "++" in C# -


public class encryptval { private encryptval(t value) { set( value ); }

    // encrypt public bool set(t value) {}  // decrypt & return (t)value; public t get()     {}  public static implicit operator encryptval<t>(t value) {     //shuffle bits     return new encryptval<t>(value); }  public static implicit operator t(encryptval<t> value) {     //unshuffle bits     return value.get(); ///// error ... } } 

i couldnt overload + operator & ++ operator. how can this?

usage:

encryptval<int> e = 42; encryptval<int> f = 1; console.writeline("decrypt int count \t= {0:d}", f.get()); // ok console.writeline("decrypt int count \t= {0:d}", f); // error console.writeline("decrypt int count \t= {0:d}", e); //how? 

to overload + or ++ add + / ++ operators want...

public static encryptval<t> operator ++(encryptval<t> value) {     throw new notimplementedexception(); // implementation here } public static encryptval<t> operator +(encryptval<t> lhs, string rhs) {     throw new notimplementedexception(); // implementation here } public static encryptval<t> operator +(encryptval<t> lhs, encryptval<t> rhs) {     throw new notimplementedexception(); // implementation here } public static encryptval<t> operator +(encryptval<t> lhs, int rhs) {     throw new notimplementedexception(); // implementation here } public static encryptval<t> operator +(bool lhs, encryptval<t> rhs) {     throw new notimplementedexception(); // implementation here } 

it unclear how relates rest of question, though. in particular, console.writeline going want public override tostring() more else.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -