Eg: string s=”jasd%^$#32143”;
Program:
using System;
namespace String
{
class PlayWithString
{
static void Main(string[] args)
{
string str = "atsd %$&2143";// Print str's Value
Console.WriteLine(str);
// Showing 4th Position of String--
string str2 = "India";
int Pos = 4;
char ch = str2[Pos];
Console.WriteLine(ch);
//string substr = str2.substring(pos);
////console.writeline(substr);
//char ch2 = 'i';
//char ch3 = str2.IndexOf(ch2, ch2+1);
//Console.WriteLine(ch3);
//Substring--
// Trim- Remove White Spaces from String L-R --
string lrgstr = " Soumik Mukherjee ";
string smlstr = lrgstr.Trim();
Console.WriteLine(smlstr);
//String fomat-
string Sentence = "{0} Is Metro City of
{1}";
string City = "Kolkata";
string Country = "India";
string ResultString = string.Format(Sentence, City,
Country);
Console.WriteLine(ResultString);
Console.ReadKey();
}
}
}
No comments:
Post a Comment