Difference between String and string in c#
There is not a big difference between String and string in C#.
String is an object in the System class. So whenever you declare the using System namespace in your class. You can use the String object.
string is a language specific type in .Net Framework itself.(CLS -> Common Languge Specification).
For ex:
--------
using System;
namespace Test
{
public class Test
{
public void TestMethod()
{
String s1 = "Change Is The Only Constant In The World.";
Console.WriteLine(s1);
Console.WriteLine(Environment.NewLine);
string s2 = "Think big acheive big.";
Console.WriteLine(s2);
}
public static void Main()
{
Test t = new Test();
t.TestMethod();
}
}
}
Output:
-------
Change Is The Only Constant In The World.
Think big acheive big.
String is an object in the System class. So whenever you declare the using System namespace in your class. You can use the String object.
string is a language specific type in .Net Framework itself.(CLS -> Common Languge Specification).
For ex:
--------
using System;
namespace Test
{
public class Test
{
public void TestMethod()
{
String s1 = "Change Is The Only Constant In The World.";
Console.WriteLine(s1);
Console.WriteLine(Environment.NewLine);
string s2 = "Think big acheive big.";
Console.WriteLine(s2);
}
public static void Main()
{
Test t = new Test();
t.TestMethod();
}
}
}
Output:
-------
Change Is The Only Constant In The World.
Think big acheive big.