Interface definition
public interface IPayeePayrollRunInitialPayElementData : IPayeePayrollRunPayElementData
But in my code the BaseType of my interface is null. I cannot make any sense of this!
To declare an interface, use interface keyword. It is used to provide total abstraction. That means all the members in the interface are declared with the empty body and are public and abstract by default. A class that implements interface must implement all the methods declared in the interface.
GetInterface(String) Method This method is used to search for the interface with the specified name. Syntax: public Type GetInterface (string name); Here, it takes the string containing the name of the interface to get. For generic interfaces, this is the mangled name.
The base type is the type from which the current type directly inherits. Object is the only type that does not have a base type, therefore null is returned as the base type of Object.
What Does Interface Mean? Interface, in C#, is a code structure that defines a contract between an object and its user. It contains a collection of semantically similar properties and methods that can be implemented by a class or a struct that adheres to the contract.
Because it's defined to be so?
Interfaces inherit from zero or more base interfaces; therefore, this property returns null if the Type object represents an interface. The base interfaces can be determined with GetInterfaces or FindInterfaces.
From Type.BaseType
page;
Interfaces inherit from zero or more base interfaces; therefore, this property returns null if the Type object represents an interface. The base interfaces can be determined with
GetInterfaces
orFindInterfaces
.
public interface IPayeePayrollRunInitialPayElementData : IPayeePayrollRunPayElementData
{ }
public interface IPayeePayrollRunPayElementData
{ }
class Program
{
static void Main(string[] args)
{
foreach (Type tinterface in typeof(IPayeePayrollRunInitialPayElementData).GetInterfaces())
{
Console.WriteLine(tinterface.FullName);
}
}
}
Output will be;
IPayeePayrollRunPayElementData
Here is a DEMO
.
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