Skip to content
Advertisement

NVarChar to C# Data Types

The database stores nvarchar, I retrieve the information and I’d like to jam it into C# data types without any declarative conversion code.

Can you implicitly convert nvarchar to C# data types? (e.g. nvarchar to int)

Advertisement

Answer

Nvarchar is a string, if you want to turn it in to a int you will have to go through some kind of conversion as I could have “Potato” in the column, what int would that map to?

Here is a listing of all of the SQL types and what C# types they map to. So if you want an int in C# without conversion your only option is an int in Sql.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement