Basic Example of String literal and string concatenation

Amatya
Posted by Amatya under C# category on | Points: 40 | Views : 1046
String literal and string concatenation

string s1, s2;
s1 = "DotNet";
s2 = "Funda";
string full= s1 + s2;
Console.WriteLine(full);
char[] name = {'a','m','a','t','y','a'};
string nameprint = new string(name);
Console.Writeline(nameprint);
string[] arr = {"Hello", "Mr","Amatya"}; //method returning string
string msg = String.Join("",arr);
Console.WriteLine(msg);
DateTime dat = new DateTime(2017,17,01,14,54,1);
string chat = String.Format("Message Sent at {0:t}", dat);
Console.WriteLine("Message: {0}",chat);


Output
DotNetFunda
amatya
Hello Mr Amatya
Message:Message sent at 2:54PM

Comments or Responses

Login to post response