Friday, 6 April 2012

IEQUATABLE INTERFACE



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication
{
    class Program : IEquatable
    {
        private int id;
        private string name;
        private double price;
        public Program(int a, string b, int c)
        {
            this.id = a;
            this.name = b;
            this.price = c;
        }
        public bool Equals(Program others)
        {
            return (this.id == others.id) && (this.name == others.name) && (this.price == others.price);
        }
        static void Main(string[] args)
        {
            Program p = new Program(1, "vijay", 2);
            Program p1 = new Program(1, "vijay", 9);
            if (p.Equals(p1))
                Console.WriteLine("the objects are equal");
            else
                Console.WriteLine("not equal");
        }
    }
}

No comments:

Post a Comment

CRUD operations using AngularJS in Asp.Net MVC

In this article I will show you how to perform CRUD operations in Asp.Net MVC5 using AngularJS. Add AngularJS using the Manage Nuget Pack...