0% found this document useful (0 votes)
8 views2 pages

Program 9

Program

Uploaded by

cwales559
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Program 9

Program

Uploaded by

cwales559
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Build Clone able objects-

using System;
class Program
{
static void Main()
{
string[] arr = { "Amit", "Nitin", "Ankit", "Sunny", "Rahul" };
string[] arrCloned = arr.Clone() as string[];

Console.WriteLine(string.Join(",", arr));
Console.WriteLine(string.Join(",", arrCloned));
Console.ReadLine();
}
}

Build Comparable objects-

using System;

namespace StringComapreSample
{
class Program
{
static void Main(string[] args)
{
string author1 = "Mahesh Chand";
string author2 = "Praveen Kumar";
string author3 = "Mahesh Chand";

// Compare strings using String.Equals


if (String.Equals(author1, author2))
Console.WriteLine($"{author1} and {author2} have same value.");
else
Console.WriteLine($"{author1} and {author2} are different.");

if (String.Equals(author1, author3))
Console.WriteLine($"{author1} and {author3} have same value.");
else
Console.WriteLine($"{author1} and {author3} are different.");

// Use CompareTo method


if (author1.CompareTo(author2) == 0)
Console.WriteLine($"Both strings have same value.");
else if (author1.CompareTo(author2) < 0)
Console.WriteLine($"{author1} precedes {author2}.");
else if (author1.CompareTo(author2) > 0)
Console.WriteLine($"{author1} follows {author2}.");
Console.ReadLine();

}
}
}

You might also like