Is there a workaround for overloading the assignment operator in C#?

you can use the ‘implicit’ keyword to create an overload for the assignment:

Suppose you have a type like Foo, that you feel is implicitly convertable from a string.
You would write the following static method in your Foo class:

public static implicit operator Foo(string normalString)
{
    //write your code here to go from string to Foo and return the new Foo.
}

Having done that, you can then use the following in your code:

Foo x = "whatever";

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)