iMemew
iMemew

Reputation: 59

How to check if the variable is a String

I have a simple problem,

dtERP value = 2885,78,89,78A;

for (int i = 0; i < dtERP.Rows.Count; i++)
{
    for (int j = 0; j < dtERP.Columns.Count; j++)
    {
        object field = dtERP.Rows[j]["QTY"];
        if (field != int)
        {

        }
    }
}

How can I validate my field if the value is string?

Upvotes: 2

Views: 2670

Answers (2)

Djs75
Djs75

Reputation: 5

You can do a .GetType() on the variable/instance.

Upvotes: 0

Salah Akbari
Salah Akbari

Reputation: 39966

You can use the is operator. Something like this:

if(field is string)

Upvotes: 3

Related Questions