C# Programming - Interfaces - Discussion

Discussion Forum : Interfaces - General Questions (Q.No. 15)
15.
Which of the following is the correct way to implement the interface given below?
interface IPerson
{ 
    String FirstName
    {
        get;
        set; 
    } 
}
class Employee : IPerson
{
    private String str; 
    public String FirstName
    {
        get
        { 
            return str;
        } 
        set
        { 
            str = value;
        } 
    } 
}
class Employee
{
    private String str;
    public String IPerson.FirstName
    { 
        get
        { 
            return str;
        } 
        set
        { 
            str = value;
        } 
    } 
}
class Employee : implements IPerson
{
    private String str; 
    public String FirstName
    { 
        get
        { 
            return str;
        } 
        set
        {
            str = value; 
        } 
    } 
}
None of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
1 comments Page 1 of 1.

Rajnish said:   1 decade ago
Ans B: public String IPerson. FirstName in this line give the error due to not public.

Ans C: class Employee : implements IPerson.

Implements is not correct syntax.

So A is correct.

Post your comments here:

Your comments will be displayed after verification.