Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NVarChar to C# Data Types

Tags:

c#

sql

asp.net

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)

like image 479
user3308043 Avatar asked Feb 12 '23 03:02

user3308043


1 Answers

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.

like image 58
Scott Chamberlain Avatar answered Feb 15 '23 11:02

Scott Chamberlain