mirror of
https://github.com/github/codeql.git
synced 2025-12-19 02:13:17 +01:00
33 lines
687 B
C#
Executable File
33 lines
687 B
C#
Executable File
class RecursiveEquals
|
|
{
|
|
class Bad
|
|
{
|
|
private int i = 0;
|
|
public override bool Equals(object rhs)
|
|
{
|
|
if (rhs.GetType() != this.GetType()) return false;
|
|
return Equals(rhs);
|
|
}
|
|
|
|
public bool Equals(Bad rhs)
|
|
{
|
|
return (rhs != null && this.i == rhs.i);
|
|
}
|
|
}
|
|
|
|
class Good
|
|
{
|
|
private int i = 0;
|
|
public override bool Equals(object rhs)
|
|
{
|
|
if (rhs.GetType() != this.GetType()) return false;
|
|
return Equals((Good)rhs);
|
|
}
|
|
|
|
public bool Equals(Good rhs)
|
|
{
|
|
return (rhs != null && this.i == rhs.i);
|
|
}
|
|
}
|
|
}
|