Difference between string and String in C#

watch_later 12/21/2020

Introduction

In this article I will explain the difference between string and String in c# as well as the guidelines for the use of each. Many times i got this questions from my junior's who working with me in my organization as well as developers who is beginner in the IT sector, There are many articles related this question already available in the internet, but in this article I will explain difference between string and String in c# with example. So it would be more helpful to understand for students as well as beginner developers.


Requirement

What is string?

Differentiate between string and String in C# with example.

Implementation


What is string?

As per the C# programming guideline provided by Microsoft, a string is an object of type String whose value is plain text, or it is a sequential collection of characters.

string Vs. String

In the C#, the keyword string is an alias of String. So, string and String both are equivalent and technically, there is no difference.

I recommended to use string when you're referring to an object.

Example

string _value = "Nikunj Satasiya";

And I recommended to use String or System.String while you referring specifically to the class, and want you use any method available in the String class.

Example 

string _value = String.Format("Hi, {0}", username);
if (String.IsNullOrEmpty(username))
   {
 
     }
String in C#

Summary

In this article, we learned there is no differentiate between string and String in C# and both are equivalent.

Codingvila provides articles and blogs on web and software development for beginners as well as free Academic projects for final year students in Asp.Net, MVC, C#, Vb.Net, SQL Server, Angular Js, Android, PHP, Java, Python, Desktop Software Application and etc.

Thank you for your valuable time, to read this article, If you like this article, please share this article and post your valuable comments.

Once, you post your comment, we will review your posted comment and publish it. It may take a time around 24 business working hours.

Sometimes I not able to give detailed level explanation for your questions or comments, if you want detailed explanation, your can mansion your contact email id along with your question or you can do select given checkbox "Notify me" the time of write comment. So we can drop mail to you.

If you have any questions regarding this article/blog you can contact us on info.codingvila@gmail.com

sentiment_satisfied Emoticon