TryGetValue Method
The TryGetValue method allows you to get the current value for the specified column.
The method returns true when the row contains the specified column;
otherwise it returns false and outputs null.
This method does not consider row state and can be called for rows
in any DataRowState.
Namespace: PocoDataSet.Data
Assembly: PocoDataSet.Data.dll
// 1. Create an empty data set
IDataSet dataSet = DataSetFactory.CreateDataSet();
// 2. Create an empty data table
IDataTable departmentDataTable = dataSet.AddNewTable("Department");
departmentDataTable.AddColumn("Id", DataTypeNames.INT32);
departmentDataTable.AddColumn("Name", DataTypeNames.STRING);
// 3. Create a new row by AddNewRow method on data table, the row state is Added
IDataRow departmentDataRow = departmentDataTable.AddNewRow();
departmentDataRow["Name"] = "Emergency";
// 4. Call TryGetValue method to get "Emergency" value for the Name column
object? departmentName = null;
bool hasName = departmentDataRow.TryGetValue("Name", out departmentName);
// 5. Call TryGetValue method for a non-existing column and observe that it returns false and outputs null
bool hasCode = departmentDataRow.TryGetValue("Code", out departmentName);
Table of Content POCO DataSet API References POCO DataSet Types DataRow Members
Business Process Programming in .Net
© 2004–2026 Laskarzhevsky Software Inc.
Unless otherwise noted, the content of this website is licensed under the
Creative Commons Attribution 4.0 International License (CC BY 4.0).
Code examples are provided under the MIT License.
You are free to share and adapt the material provided that appropriate
credit is given and any modifications are clearly indicated.
The information provided on this website is for educational purposes only.
The author and publisher make no warranties regarding the completeness
or suitability of the information and are not responsible for any damages
resulting from its use.