I have a class that contains Append-like members for each primitive type, string and INetSerializable:
public class TypeAppender
{
public void Append(int i ) {}
public void Append(double d) {}
public void Append(string s){}i){}
public void Append(INetSerializable ins){}
}
From a different class, I want to call this method "generically so to speak", by passing Object
say I have something like that:
class SomeClientClass
{
TypeAppender _appender=new TypeAppender ();
Dictionary<string, Object> _cmdTable =new Dictionary<string, Object>();
public void Process()
{
foreach(KeyValuePair<string, Object> pair in cmdTable )
{
_appender.Append(pair.Key);
Object obj = pair.Value;
if (obj is int)
_appender..Append((int)obj);
else if (obj is double)
_appender..Append((double)obj);
else if (obj is char)
_appender..Append((char)obj);
else if (obj is string)
_appender..Append((string)obj);
}
}
public void AddParam<T>(string key, T value)
{
_cmdTable.Add(key, value);
}
}
Question #1: Will pair.Value be unboxed to a correct primitive? s
Question #2: Any problesm with AddParam member function?
Thanks