using System;
public class Program
{
public static void Main()
for (int i = 0; i < 100; i++)
var f = 32f;
if (!SetStruct<float>(ref f, 45f))
Console.WriteLine("Some message");
}
public static bool SetStruct<T>(ref T currentValue, T newValue) where T : struct
if(currentValue.Equals(newValue))
return false;
currentValue = newValue;
return true;