I need to call the function that will get the value of a datatable cell with the ColIndex, either a text (column name) or an integer (columnindex).To avoid writing two functions that, I wrote this code:Public Function DTableCellValue(ByRef RowData As DataRow, _                                    ByVal ColIndex As Object, _                                    Optional ByVal DefaultVal As String = ) As Object        Try            Dim ret As Object = RowData.Item(ColIndex)            If IsDBNull(ret) Then                Return DefaultVal            Else                Return ret            End If        Catch ex As Exception            Throw        End Try    End FunctionCan you tell me if it uses bad coding practices or is potentially problematic?
Calling functions with different variable types
.net;vb.net;.net datatable
If you use this method quit often by passing an Integer you will get performance problems because of the boxing and unboxing of the struct.  My advice would be to write two methods one using an Integer and the other using a String as argument.Based on the naming guidelines you should name methods by using a verb or a verb phrase. DTableCellValue looks by its name more as a property than a method.  Based on the same guidelines method arguments should be named using camelCase casing. Although VB.NET isnt case sensitive I would like to suggest to follow these guidelines.  The try..catch is in its current form senseless because if an exception is thrown you are just rethrowing it.  A construct like  If condition Then    Return ValueElse    Return otherValueEnd If  can be simplified by removing the redundant else like so  If condition Then    Return ValueEnd If Return otherValuebecause if the condition is true the else won't be reached.  Implementing the mentioned points (leaving aside the method name) leads to two methods like so  Public Function DTableCellValue(ByRef rowData As DataRow, _                                    ByVal colIndex As Integer, _                                    Optional ByVal defaultVal As String = ) As Object    Dim ret As Object = rowData.Item(colIndex)    If IsDBNull(ret) Then        Return defaultVal    End If    Return retEnd FunctionPublic Function DTableCellValue(ByRef rowData As DataRow, _                                    ByVal colIndex As String, _                                    Optional ByVal defaultVal As String = ) As Object    Dim ret As Object = rowData.Item(colIndex)    If IsDBNull(ret) Then        Return defaultVal    End If    Return retEnd Function