0
Answer

interlock exchange issue

George George

George George

16y
3.3k
1

Hello everyone,


How to fix the compile error when interlock exchange a bool type variable?

[Code]
    public static void Main()
    {
        bool b = false;

        // error CS0452: The type 'bool' must be a reference type in order to use it as parameter
        // 'T' in the generic type or method 'System.Threading.Interlocked.Exchange<T>(ref T, T)'
        bool a = Interlocked.Exchange(ref b, true);

        return;
    }
[/Code]


thanks in advance,
George

Next Recommended Forum