CSharp · Console
using System;
public class Thing
{
public string Property {get; set;}
public int AnotherProperty {get; set;}
public string OneMore {get; set;}
public bool Verbose()
{
bool hasChanged = false;
hasChanged |= Property != (Property = "Value");
hasChanged |= AnotherProperty != (AnotherProperty = 42);
hasChanged |= OneMore != (OneMore = "They get it");
return hasChanged;
}
public bool Clever()
{
return Property != (Property = "Value") ||
AnotherProperty != (AnotherProperty = 42) ||
OneMore != (OneMore = "They get it");
}
public override string ToString()
{
return String.Format("Property: '{0}' AnotherProperty: {1} OneMore: '{2}'",Property,AnotherProperty,OneMore);
}
public static void Main()
{
var thing = new Thing();
Console.WriteLine(String.Format("Clever: {0} '{1}'",thing.Clever(),thing));
thing = new Thing() { Property = "Value"};
Console.WriteLine(String.Format("Clever: {0} '{1}'",thing.Clever(),thing));
thing = new Thing();
Console.WriteLine(String.Format("Verbose: {0} '{1}'",thing.Verbose(),thing));
thing = new Thing() { Property = "Value"};
Console.WriteLine(String.Format("Verbose: {0} '{1}'",thing.Verbose(),thing));
}
}