I'm trying to return multiple values from a function in which I pass a parameter and store it in variable ZDO_S
In variable ZDO_S I'm trying to store two values which I will get by passing single value 'row["TVM_LS_NO"].ToString()' which is obtain from database in 'getdo' function
var ZDO_S = getDo(row["TVM_LS_NO"].ToString());
Here is the method :
private static (string TVD_LS_NO, string TVD_INV_NO) getDo(string DoNo)
{
try
{
using (OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["Oracle_To_Sql.Properties.Settings.Setting"].ToString()))
{
string query = "select SUBSTR(TVD_DO_ITEM_NO,'1','10') from T_VEHICLE_DTL1 where TVD_LS_NO=:TVD_LS_NO";
OracleCommand myCommand = new OracleCommand(query, con);
DataTable dt = new DataTable();
OracleDataAdapter da = new OracleDataAdapter(myCommand);
da.SelectCommand = new OracleCommand(query, con);
da.Fill(dt);
foreach (DataRow row in dt.Rows)
{
string TVD_LS_NO = row["TVD_LS_NO"].ToString();
string TVD_INV_NO = row["TVD_INV_NO"].ToString();
}
return (TVD_LS_NO, TVD_INV_NO);
}
}
catch (Exception ex)
{
throw;
}
}
Expected values should be return and stored in ZDO_S variable.
actual getting error "cannot assign void to an implicitly-typed variable" at
var ZDO_S=getDo(row["TVM_LS_NO"].ToString());IDentifier expected at
private static (string TVD_LS_NO, string TVD_INV_NO) getDo(string DoNo)Since 'Program.getDo(String) returns void ,a return keyword must be followed by an object expression at
return (TVD_LS_NO, TVD_INV_NO);
TVD_LS_NOandTVD_INV_NOare defined in theforeachblock and therefore aren't visible at the point you doreturn.Tupel<string, string>. They have the disadvantage of only having properties named "Item1" and "Item2" instead of the names you want but otherwise work in the same way.tryParsewithoutkeyword, which is not very appealing for me either).