i have one interface
/// <summary>
/// Summary description for IBindable
/// </summary>
public interface IBindable<T>
{
// Property declaration:
T Text
{
get;
set;
}
}
Now I want to implement this interface in my class
public class MyTextBox :IBindable<string>
{
//now i how can i implement Text peroperty here
}
I don’t want to implement it like
string IBindable<string>.Text
{
get { return "abc";}
set { //assigne value }
}
I want to implement it like
public string Text
{
get{} set {}
}
You are free to do this. This is an implicit interface implementation.
The following is valid C#:
When you implement an interface, you are free to implement it implicitly, as above, or explicitly, which would be your second option:
The difference is in usage. When you use the first option, the
Textproperty becomes a publicly visible property on the type itself (MyTextBox). This allows:However, if you implement it explicitly, you need to be using your interface directly: