C# Interview Questions!!
class ObjectA
{
private int val;
public ObjectA(int i)
{
val = i;
}
}
struct ObjectB
{
private int val;
public ObjectB(int i)
{
val = i;
}
}
static void Main(string[] args)
{
ObjectA obj1 = new ObjectA(10);
ObjectA obj2 = new ObjectA(10);
ObjectB str1 = new ObjectB(10);
ObjectB str2 = new ObjectB(10);
Console.WriteLine(obj1.Equals(obj2));
Console.WriteLine(str1.Equals(str2));
Console.ReadLine();
}
}
OutPut:
False
True
{
private int val;
public ObjectA(int i)
{
val = i;
}
}
struct ObjectB
{
private int val;
public ObjectB(int i)
{
val = i;
}
}
static void Main(string[] args)
{
ObjectA obj1 = new ObjectA(10);
ObjectA obj2 = new ObjectA(10);
ObjectB str1 = new ObjectB(10);
ObjectB str2 = new ObjectB(10);
Console.WriteLine(obj1.Equals(obj2));
Console.WriteLine(str1.Equals(str2));
Console.ReadLine();
}
}
OutPut:
False
True
Comments