Console Application using Operator Overload in C# 1.1 and 2.0 (Dot Net)
Console Application using Operator Overload in C# 1.1 and 2.0 (Dot Net)
// Operator overload in C#
using System;
namespace operatoroverload
{
class Class1
{
static void Main()
{
float i,j;
Console.WriteLine("Enter the first value A1");
i=float.Parse(Console.ReadLine());
Console.WriteLine("Enter the first value A2");
j=float.Parse(Console.ReadLine());
op a=new op();
op b=new op();
a.x=i;
b.x=j;
op A3=a+b;
op A4=a-b;
op A5=a*b;
op A6=a/b;
{
if (a>b)
{
Console.WriteLine("A1 is greater than A2");
}
else if(a
{
Console.WriteLine("A2 is greater than A1");
}
}
{
if(a == b)
{
Console.WriteLine(" A1 is equal to A2 ");
}
/* else if(A1 != A2)
{
Console.WriteLine(" A1 is not equal to A2 ");
} */
}
Console.WriteLine(" A1+A2 is {0} ",A3.x);
Console.WriteLine(" A1-A2 is {0} ",A4.x);
Console.WriteLine(" A1xA2 is {0} ",A5.x);
Console.WriteLine(" A1/A2 is {0} ",A6.x);
Console.ReadLine();
}
}
class op
{
public float x;
/*public op(float y)
{
this.x = y;
}*/
public static op operator+(op a,op b)
{
op c=new op();
c.x=a.x+b.x;
return(c.x);
}
public static op operator-(op a, op b)
{
op c = new op();
c.x = a.x-b.x;
return(c.x);
}
public static op operator * (op a,op b)
{
op c=new op();
c.x = a.x*b.x;
return(c.x);
}
public static op operator/(op a,op b)
{
op c=new op();
c.x=a.x/b.x;
return(c.x);
}
public static bool operator>(op a,op b)
{
return(a.x > b.x);
}
public static bool operator < (op a,op b)
{
return(a.x } public static bool operator == (op a,op b) { return(a.x==b.x); } public static bool operator != (op a, op b) { return (a.x != b.x); } } }
-
Introduction into web site performance management
| By saint | in General
article on how to start monitoring web application performance - practice, tools and recommendations. ...
-
Optimize Your Computer by Cleaning It Up
| By btucker | in Computers
Nobody likes a slow computer. In fact when you computer slows down it makes you aggravated. Here are a couple ways ...
-
Optimizing the Performance of your Laptop and Personal Computers
| By lonelysole | in Computers
There are many reasons that caused the computer to run slowly over time. Let’s look at some of the most common ca...
-
THE STORY OF C++
| By msathishssn | in Americas
C++ (read as "C Plus Plus") is a low-level, object-oriented, standard programming programming language. I...
-
How to Create a Search Feature with PHP and MySQL | By Junedseo | in Programming
Developing a robust, interactive and engaging Web site involves many different avenues, such as interactive pop-out...
-
What Is Hacking? | By faris_jayz | in Programming
It is not that difficult to hack into a computer system. The most popular definition for hacking is the act of obta...
-
How do I enable JavaScript in browser? | By myjobs | in Programming
way to enable the javascript in different types of browser....
-
How to Set Up a Local Development Environment in Ubuntu | By havard | in Programming
Learn how to set up a local development environment in Ubuntu that set up your websites on the fly....
-
XA Transaction - Solution for Transaction More Than One Database | By H4d1 | in Programming
Have you ever think that it's too difficult for making database transaction in two different places (or databases) ...
-
Javascript functions for : trim, right trim, left trim, no Apostrophe, is Empty , is Digit , VarChar To Number , is integer , check Is Zero , Get Que | By xxris | in Programming
Javascript functions for : trim, right trim, left trim, no Apostrophe, is Empty , is Digit , VarChar To Number , i...
-
C# Code for Diagonal Addition of Two Matrix (Dotnet) | By xxris | in Programming
C# Code for Diagonal Addition of Two Matrix (Dotnet)...
-
C# Code for converting Digits to words from number 1 to 100099 (Dotnet) | By xxris | in Programming
This Program is For numbers less Than equal to 100099....
-
C# code for Transpose Of Matrix (C Sharp) ( Dot net) | By xxris | in Programming
C# code for Transpose Of Matrix (C Sharp) ( Dot net)...
-
Simple welcome and Console Print application in C# ( C sharp ) (Dot Net) | By xxris | in Programming
Simple welcome and Console Print application in C# ( C sharp ) (Dot Net)...








No comments yet.