Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 817
  • Last Modified:

PropertyDescriptor.PropertyType check if int ???

How can I check if PropertyDescriptor.PropertyType is type int?
PropertyDescriptor objPropDesc;
... set the objPropDesc ...
and...
if (objPropDesc.PropertyType is Int16 || objPropDesc.PropertyType is Int32 || objPropDesc.PropertyType is Int64)

this if never works...
0
glowas
Asked:
glowas
1 Solution
 
glowasAuthor Commented:
I did it this way for now, but I don't like it because it is only comparing the type name.
if (objPropDesc.PropertyType.FullName == "System.Int16" .....)
But it works...
Any better solutions?
0
 
b1xml2Commented:
Type t = Type.GetType(objPropDesc.PropertyType.FullName)
if (t == typeof(short))
{
 // short is System.Int16
 ...
}
elseif (t == typeof(int))
{

}
elseif (t == typeof(Int64))
{

}
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now