In the below 2 links i found that Object and object are interchangeable :
Difference between Object and object
c#: difference between "System.Object" and "object"
But i am just not able to understand why i can't make this below code to work, if Object and object are interchangeable:
Code that didn't work with "Object" :
class A : Object
{
public int x = 5;
}
class B : A
{
static void Main()
{
System.Console.WriteLine(new B().x);
}
}
Output:
The type or namespace name 'Object' couldnot be found (are you missing a using directive or an assembly reference?)
Code that worked with "object" :
class A : object
{
public int x = 5;
}
class B : A
{
static void Main()
{
System.Console.WriteLine(new B().x);
}
}
Output:
5
To bring Object
in scope you need to import System
namespace as opposed to object
which is a keyword(alias to Object).
add this to your cs file
using System;
or even simpler use fully qualified name.
class A : System.Object
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With