2014-11-06 71 views

回答

4

使用typeof(T)。就像這樣:

public void FilBuff<T>(T p_tInput) 
{ 
    if(typeof(T) == typeof(string)) 
    { 
     m_bBuff = System.Text.Encoding.ASCII.GetBytes((string)p_tInput); 
    } 
} 

順便說一句,你與仿製藥(不是模板)做的是有點古怪。在你的情況下使用重載方法可能會更好。