C# Code - Strange error

.ToString()?

Why does this code:


 // Get the current assembly view
 EpiDataView cav = (EpiDataView)oTrans.EpiDataViews["CurrAsm"];
 string stWidth = cav.dataView[cav.Row]["Character01"];


Give the error:  Cannot implicitly convert type 'object' to 'string'.




You get this error because  cav.dataView[cav.Row]["Character01"] is object, hence the [ ]. And stWidth is a string. So to remedy this add a .ToString() on the end of  cav.dataView[cav.Row]["Character01"] or type cast it. whichever works for you.


 // Get the current assembly view
 EpiDataView cav = (EpiDataView)oTrans.EpiDataViews["CurrAsm"];
 string stWidth = cav.dataView[cav.Row]["Character01"].ToString();


 // Get the current assembly view
 EpiDataView cav = (EpiDataView)oTrans.EpiDataViews["CurrAsm"];
 string stWidth = (string)cav.dataView[cav.Row]["Character01"];


Regards,

Aaron


This is what I researched  http://bfy.tw/7FNm

 

 

Rob Bucek

Production Control Manager

D&S Manufacturing

301 E. Main St.

Black River Falls, WI 54615

715-284-5376 Ext. 311

Mobile: 715-896-3119

rbucek@...

Visit our newly redesigned Website at www.dsmfg.com

 

From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com]
Sent: Tuesday, August 16, 2016 3:31 PM
To: vantage@yahoogroups.com
Subject: [Vantage] C# Code - Strange error

 

 

Why does this code:

 

 // Get the current assembly view
 EpiDataView cav = (EpiDataView)oTrans.EpiDataViews["CurrAsm"];
 string stWidth = cav.dataView[cav.Row]["Character01"];

 

Give the error:  Cannot implicitly convert type 'object' to 'string'.