1
using System.Collections;
using System;

public class Counter<T>
{
    private int pivot = 0;
    private readonly int arraySize = 256;
    private bool startCheck = false;

    T[] baskets;

    public T Count
    {
        get
        {
            return baskets[pivot];
        }
    }

    public void CountPlus(T plusValue)
    {
        if(!startCheck)
        {
            startCheck = true;

            baskets[pivot] = plusValue;
        }
        else
        {
            int previousPivot = pivot;

            pivot++;

            if( previousPivot == arraySize - 1 )
            {
                pivot = 0;
            }

            checked
            {
                try
                {
                    baskets[pivot] = baskets[previousPivot] + plusValue;
                }
                catch(OverflowException ofe)
                {
                    Debug.Log("=*=*=*=*=*=*=*=*= OverflowException =*=*=*=*=*=*=*=*=*=");
                }
            }

        }
    }
}

こんにちは~

このコードを実行したいのですが、エラー メッセージが表示されます

error CS0019: Operator '+' cannot be applied to operands of type 'T' and 'T'

このエラーを解決するにはどうすればよいですか?

4

3 に答える 3