我有一个object 如何得到它原来的类型???比如:
object tempobj;
byte[] Data;
tempObj=Data; if(tempObj 的类型是byte[]) //这里该怎么写???????????
{
//说明是byte[],作相应处理
}
else
{
//作其他处理
}
object tempobj;
byte[] Data;
tempObj=Data; if(tempObj 的类型是byte[]) //这里该怎么写???????????
{
//说明是byte[],作相应处理
}
else
{
//作其他处理
}
解决方案 »
- winform 程序启动后第一次调用webservice很慢
- 请教一道面试题
- 关于imagelist控件
- 怎样建立.net2003与sqlserver6.5数据库的连接(在线等)
- 菜鸟的问题
- 應用程式中發生伺服器錯誤。
- 同志救急
- 小问题,小得不能再小的问题。我就是不知道!
- 请帮忙:如何用C#写调用WebService方法的客户端代码(100分!!!)
- 如何用C#开发Win2000下的Service ???
- 客户端如何获取IIS里面虚拟目录的路径?或者如何将XML的文件生成到客户端的system32目录?
- -----大家注意!从小问题发现大情况!个人BLOG陷阱大批露!·同时强烈要求各位星级老大给于强烈批判!!
要把他转化回来,试试强制转化
如果强制转化不行的话,就只能自己写函数转了
byte[] Data = new byte[100];
tempobj=Data;if (tempobj is byte[])
{
byte[] x = (byte[])tempobj; Console.WriteLine(x.Length);
}orobject tempobj;
byte[] Data = new byte[100];
tempobj=Data;byte[] x = tempobj as byte[];if ( x != null)
{
Console.WriteLine(x.Length);
}
byte[] Data = new byte[100];
tempobj=Data;if (tempobj is byte[])
{
byte[] x = (byte[])tempobj; Console.WriteLine(x.Length);
}orobject tempobj;
byte[] Data = new byte[100];
tempobj=Data;byte[] x = tempobj as byte[];if ( x != null)
{
Console.WriteLine(x.Length);
}
byte[] Data;
tempObj=Data; if(tempObj.GetType() == (new byte[0]).GetType() )
{
//说明是byte[],作相应处理
}
else
{
//作其他处理
}
byte[] Data;
tempObj=Data;
if((tempObj as byte[]) != null)
{
//说明是byte[],作相应处理
}
else
{
//作其他处理
}
byte[] Data = new byte[100];
tempobj=Data;if (tempobj is byte[])
{
byte[] x = (byte[])tempobj; Console.WriteLine(x.Length);
}orobject tempobj;
byte[] Data = new byte[100];
tempobj=Data;byte[] x = tempobj as byte[];if ( x != null)
{
Console.WriteLine(x.Length);
}generally, people doobject tempobj;
byte[] Data = new byte[100];
tempobj=Data;if (tempobj is byte[])
{
byte[] x = (byte[])tempobj; Console.WriteLine(x.Length);
}orobject tempobj;
byte[] Data = new byte[100];
tempobj=Data;byte[] x = tempobj as byte[];if ( x != null)
{
Console.WriteLine(x.Length);
}generally, people doobject tempobj;
byte[] Data = new byte[100];
tempobj=Data;if (tempobj is byte[])
{
byte[] x = (byte[])tempobj; Console.WriteLine(x.Length);
}orobject tempobj;
byte[] Data = new byte[100];
tempobj=Data;byte[] x = tempobj as byte[];if ( x != null)
{
Console.WriteLine(x.Length);
}
{
byte[] x = (byte[])tempobj; }