Difference Between String and string In C#

Difference Between String and string In C#


welcome to DotnetMob (CodAffection)
In this series we will discuss commonly asked c# interview questions
if you have any questions to be answered please leave that question
as comment I shall answer that question in another video as far as possible in this video we will discuss
difference between String and string you must probably heard that string is an alias for String actually String is a class in namespace System so string keyword is an alias for System.String class in this video I’ll show you what exactly it means
and there are important points to noted
let’s move to visual studio
I am going to create a c# program that shows the difference between String and string so let’s get started
I am going to declare a variable of type string using the String class strName equals Dotnet Mob and I want to print the string console.. Console.Readkey() first we run this program it shows output without any error now,I am going to .. use the namespace prefix or namespace before these two lines now I am going to remove the line that we used to import the System Namespace and when we run the program,it shows small error we are not importing System Namespace and we are using String class without specifying the namespace of the class String if I replace this
String by string program will run without any error ,now … I am going to change the comment that I already made string is not an alias for String by being more specific
we can say that string is an alias for System.String class that what we learned from this program whatever you can do with string variable can also be done with String variable also
keep in mind that you must import System Namespace or specify System namespace before String
but you don’t want to care about Namespace problem with string since it is a direct
alias for System.string class So far we have discussed the difference between String and string
this same concept can be applied in the aliases like int vs System.Int32 System.Int32 and bool Vs System.Boolean System.Boolean Class Boolean class, that is all you can check my blog post
about this topic from video description thanks for listening, Don’t forget to
subscribe my channel Dotnet Mob (CodAffection) Have a great day,Bye :☻

2 Comments

  • CodAffection says:

    https://goo.gl/RFY5C2 : Subscribe to CodAffection
    https://goo.gl/ULZsNU : String Vs StringBuilder
    https://goo.gl/i2zPcJ : Measure C# Code Execution Time
    https://goo.gl/5CSZk1 : Complete C# Tutorial

  • prabhakar p says:

    If a=1, b=2, c=3, z=26. Given a string, find all possible codes that string can generate. Give a count as well as print the strings. in csharp I need this explanation bro

Leave a Reply

Your email address will not be published. Required fields are marked *