What will be the output of the following C# code snippet?
class equality
{
public int x;
public int y;
public Boolean isequal()
{
return (x == y);
}
}
class Program
{
static void Main(string[] args)
{
equality obj = new equality();
obj.x = 5;
obj.y = 5;
Console.WriteLine(obj.isequal());
Console.ReadLine();
}
}
class equality
{
public int x;
public int y;
public Boolean isequal()
{
return (x == y);
}
}
class Program
{
static void Main(string[] args)
{
equality obj = new equality();
obj.x = 5;
obj.y = 5;
Console.WriteLine(obj.isequal());
Console.ReadLine();
}
}A. false
B. true
C. 0
D. 1
Answer: Option B
Related Questions on Functions and Methods in C Sharp
What is the purpose of a return type in a method declaration in C#?
A. To specify the access modifier of the method
B. To specify the type of data returned by the method
C. To specify the parameters of the method
D. None of the above
In C#, which keyword is used to define a method that does not return a value?
A. return
B. none
C. void
D. null
A. Add(int num1, int num2)
B. int Add(num1, num2)
C. Add(num1, num2)
D. int Add(int num1, int num2)

Join The Discussion