Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- class Name
- {
- private string fname, lname;
- public Name(string f, string l)
- {
- fname = f;
- lname = l;
- }
- public string retf()
- {
- return fname;
- }
- public string retl()
- {
- return lname;
- }
- public static Boolean operator==(Name n1, Name n2)
- {
- Boolean ans;
- if((n1.retf()==n2.retf())&&(n1.retl()==n2.retl()))
- ans=true;
- else
- ans=false;
- return ans;
- }
- public static Boolean operator!=(Name n1, Name n2)
- {
- Boolean ans;
- if ((n1.retf() == n2.retf()) && (n1.retl() == n2.retl()))
- ans = false;
- else
- ans = true;
- return ans;
- }
- }
- static void Main(string[] args)
- {
- Console.WriteLine("Enter The name of first member");
- Console.WriteLine("\nFirst Name: ");
- string input1 = Console.ReadLine();
- Console.WriteLine("Last name: ");
- string input2 = Console.ReadLine();
- Name A = new Name(input1, input2);
- Console.WriteLine("Enter The name of second member");
- Console.WriteLine("\nFirst Name: ");
- input1 = Console.ReadLine();
- Console.WriteLine("Last name: ");
- input2 = Console.ReadLine();
- Name B = new Name(input1, input2);
- if (A == B)
- {
- Console.WriteLine("\nBoth the members have same name");
- }
- else if (A != B)
- {
- Console.WriteLine("\nBoth the members have different name");
- }
- else
- {
- Console.WriteLine("\nSome error occurred");
- }
- Console.ReadLine();
- }
- }
- }
Add Comment
Please, Sign In to add comment