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'
我该如何解决这个错误?