Reverse a string
Get a Sub-String from a string
Join 2 Strings
Compare 2 Strings
Check whether a string contains particular string value or not.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
string s = "hello";
string s1 = "Prateek ";
string s2 = "World";
string rev="";
for (int i = s.Length - 1; i >= 0; i--)
{
rev = rev + s[i];
}
Console.WriteLine("String is : {0}",s);
Console.WriteLine("Reverse String is {0}", rev);
Console.WriteLine();
Console.WriteLine("Joining 2 Strings");
string s3=String.Concat(s1,s2);
Console.WriteLine(s3);
Console.WriteLine();
Console.WriteLine("Getting Sub String from a String");
string s4 = s1.Substring(1,4);
Console.WriteLine(s4);
Console.WriteLine();
Console.WriteLine("Comparing 2 Strings");
int n = string.Compare(s3, s1);
Console.WriteLine(n);
Console.WriteLine();
Console.WriteLine("Checking String value is there or not");
bool b = s1.Contains("h");
Console.WriteLine("Checked String value is : {0}",b);
Console.ReadKey();
}
}
}
Get a Sub-String from a string
Join 2 Strings
Compare 2 Strings
Check whether a string contains particular string value or not.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
string s = "hello";
string s1 = "Prateek ";
string s2 = "World";
string rev="";
for (int i = s.Length - 1; i >= 0; i--)
{
rev = rev + s[i];
}
Console.WriteLine("String is : {0}",s);
Console.WriteLine("Reverse String is {0}", rev);
Console.WriteLine();
Console.WriteLine("Joining 2 Strings");
string s3=String.Concat(s1,s2);
Console.WriteLine(s3);
Console.WriteLine();
Console.WriteLine("Getting Sub String from a String");
string s4 = s1.Substring(1,4);
Console.WriteLine(s4);
Console.WriteLine();
Console.WriteLine("Comparing 2 Strings");
int n = string.Compare(s3, s1);
Console.WriteLine(n);
Console.WriteLine();
Console.WriteLine("Checking String value is there or not");
bool b = s1.Contains("h");
Console.WriteLine("Checked String value is : {0}",b);
Console.ReadKey();
}
}
}
No comments:
Post a Comment