.NET : How do you get the Type of a null object?

前端 未结 12 1282
暗喜
暗喜 2020-11-28 13:59

I have a method with an out parameter that tries to do a type conversion. Basically:

public void GetParameterValue(out object destination)
{
    object param         


        
12条回答
  •  半阙折子戏
    2020-11-28 14:53

    The type of your destination variable is always System.Object. You could just return

    Convert.ChangeType(paramVal, System.Object).
    

提交回复
热议问题