<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Conversion of Field Type to Double in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/conversion-of-field-type-to-double/m-p/1278077#M9659</link>
    <description>&lt;P&gt;I am getting the error "System.InvalidCastException:'Unable to cast object of type 'ArcGIS.Core.Data.Field' to type&amp;nbsp; 'System.IConvertible'. I am pretty sure this worked for me before, but I got this error when I applied it to the "Shape_Area" field. If anyone encountered the same problem, how did you resolve it? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; Field areaField = modelSoilsDef.GetFields().FirstOrDefault(x =&amp;gt; x.Name.Contains("Shape_Area"));
                        var Area = Convert.ToDouble(areaField);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Apr 2023 01:20:05 GMT</pubDate>
    <dc:creator>tzz_12</dc:creator>
    <dc:date>2023-04-13T01:20:05Z</dc:date>
    <item>
      <title>Conversion of Field Type to Double</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/conversion-of-field-type-to-double/m-p/1278077#M9659</link>
      <description>&lt;P&gt;I am getting the error "System.InvalidCastException:'Unable to cast object of type 'ArcGIS.Core.Data.Field' to type&amp;nbsp; 'System.IConvertible'. I am pretty sure this worked for me before, but I got this error when I applied it to the "Shape_Area" field. If anyone encountered the same problem, how did you resolve it? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; Field areaField = modelSoilsDef.GetFields().FirstOrDefault(x =&amp;gt; x.Name.Contains("Shape_Area"));
                        var Area = Convert.ToDouble(areaField);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 01:20:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/conversion-of-field-type-to-double/m-p/1278077#M9659</guid>
      <dc:creator>tzz_12</dc:creator>
      <dc:date>2023-04-13T01:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of Field Type to Double</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/conversion-of-field-type-to-double/m-p/1278118#M9660</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;First, you don't need use Linq to find field.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Field areaField = modelSoilsDef.FindField("Shape_Area");&lt;/LI-CODE&gt;&lt;P&gt;To find spatial fields like area or length don't use strings like "Shape_Area". Name of spatial field could depend on database type. Use ArcGIS Pro SDK for these fields:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;string areaFieldName = modelSoilsDef.GetAreaField();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the last thing. As I understand you want to read row value of field "Shape_Area". Your code could look like this:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var Area =  Convert.ToDouble(row[modelSoilsDef.GetAreaField()]);&lt;/LI-CODE&gt;&lt;P&gt;If you want to read more than one row:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;string areaFieldName = modelSoilsDef.GetAreaField();

// inside row cursor

var Area =  Convert.ToDouble(row[areaFieldName]);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 06:20:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/conversion-of-field-type-to-double/m-p/1278118#M9660</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-04-13T06:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion of Field Type to Double</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/conversion-of-field-type-to-double/m-p/1278370#M9667</link>
      <description>&lt;P&gt;Thank you for your detailed solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 16:59:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/conversion-of-field-type-to-double/m-p/1278370#M9667</guid>
      <dc:creator>tzz_12</dc:creator>
      <dc:date>2023-04-13T16:59:05Z</dc:date>
    </item>
  </channel>
</rss>

