Answer the question
In order to leave comments, you need to log in
Implementing an interface in c# - is it possible to use a different name for a property/method?
It was clear where such a question came from: after a long experience of working on vb.net (as my first language), relatively recently I had a need, and most importantly, the ability to master c # (from version 7.0) At the same time, having experience with JavaScript , I didn’t have any particular difficulties with mastering the c# syntax. Of course, I still constantly draw analogies with vb.net, since I often miss a lot of its features, which are not supported in c# a priori. And now, I would like to ask experts about one such feature.
vb.net defines an interface like this:
'''<summary>Определяет объект, являющийся элементом перечисления</summary>
'''<typeparam name="T">Тип идентификатора для элемента перечисления</typeparam>
Public Interface IEnum(Of T)
'''<summary>Идентификатор элемента перечисления</summary>
ReadOnly Property ID As T
'и так далее...
End Interface
ID
I can assign a different name to the property, which is semantically closer to this particular implementation and it will look like this:'''<summary>Отрасль промышленности</summary>
Public NotInheritable Class Industry : Implements IEnum(Of Byte)
'''<summary>Код отраслевого направления</summary>
Public ReadOnly Property Code As Byte Implements IEnum(Of Byte).ID
'и так далее...
End Class
'''<summary>Сфера деятельности</summary>
Public NotInheritable Class Employment : Implements IEnum(Of Integer)
'''<summary>Тип сферы деятельности</summary>
Public ReadOnly Property Type As Integer Implements IEnum(Of Integer).ID
'и так далее...
End Class
ID
) in the classes that implement it?
Answer the question
In order to leave comments, you need to log in
_
public interface IId
{
int ID { get; set; }
}
public class Element : IId
{
public int Type
{
get
{
return ((IId)this).ID;
}
}
int IId.ID { get; set; }
}
Explicit Interface Implementation (C# Programming ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question