How can I determine if an object can ToString into value or type name?

后端 未结 6 1716
青春惊慌失措
青春惊慌失措 2021-01-19 09:38

I am writing an interop between a php service and our crm. One of the things I need to do is make sure that simple types get converted ToString() for use later in a json co

6条回答
  •  滥情空心
    2021-01-19 10:21

    Maybe you can do something similar to this:

    bool ToStringIsTyped(T myObj)
    {
        return myObj.ToString().Contains(typeof(T).FullName);
    }
    

    It may not work in all cases, but possibly could be expanded

提交回复
热议问题