-2

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 (..)";

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57
  • 1
    difference between examples : the first one can be modified, and second one is constant, it can't be modified. – iSR5 Mar 02 '20 at 00:44
  • A [`const`](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/const) cannot be modified but a regular variable can. – juharr Mar 02 '20 at 00:45

1 Answers1

0

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.

Sven Krauter
  • 922
  • 4
  • 17