Friday, December 14, 2018

C# less known facts

In this article, I will present several features of C# which are not widely known among developers.

You can overload operators:

    public static bool operator ==(Person x, Person y)
    { 
        return x.Equals(y);
    }
 
    public static bool operator !=(Person x, Person y)
    {
        return !(x == y);
    }


You can comment on arguments of a method and refer to other methods in the comment:

/// <summary>
/// Compares the content of two files created by method <see cref="BuildListFromJson(string)"/>.
/// </summary>
/// <param name="objPath"></param>
/// <param name="anotherPath"></param>
/// <returns></returns>
public static bool CompareJsonizedObjectsFromFiles(this object objPath, object anotherPath)
{

No comments:

Post a Comment