What is the best way to declare "string" variables in C #?

105 Views Asked by At

I'm a new developer and I have two questions, I researched and it wasn't very clear to me.

What is the difference between using a "string" variable to "String"?

what is the difference between the two examples below

string my_example = "title (..)";

to

const string my_example = "title (..)";

1

There are 1 best solutions below

1
On

there is no difference in the type itself. For String you need a using for namespace System, but not for string.

Same applies to Decimal/decimal, Int32/int, etc. etc.

I always use the lowercase build in c# type where possible (for DateTime you can't) Microsoft suggests to use the build in types.