Awesome q2a theme

A parameterized property in C# — how to set?

0 like 0 dislike
62 views
The preamble is duplicated from my previous question.
So it's clear from where such a question: after a long experience in vb.net (as my first language) recently I had the need, and most importantly - the opportunity to learn C# (version 7.0) At the same time, having experience with JavaScript, specific difficulties with the development of c# syntax, I did not have. Of course, yet constantly make analogies with vb.net because I often lack many of its features, which is missing in C# a priori. And now, about one of the features I would like to ask the experts.

In vb.net I can identify and use properties with parameters, and to define parameterized properties not only in classes but also in the interfaces, the parameters can be declared optional. This is a very convenient feature when you want to return (or set) a value for the property, which something depends.
Here's an example vb.net:
"'IndustryPublic NotInheritable Class Industry : Implements IEnum(Of Byte) "'Code branch directionsPublic ReadOnly Property Code As Byte Implements IEnum(Of Byte).ID "'Name industry trends"'The language in which to return the name. If the language is not set or it is not supported, it will use the language assigned in the context of the current thread.Public ReadOnly Property Name(Optional language As Language = Nothing) As String Implements IEnum(Of Byte).Name Get Return ... End Get End Property 'and so on... End Class


Digression:
I have realized that c# is inferior language vb.net from the point of view of semantics, but did not expect that in C# there is the complexity associated with seemingly basic things. And that vb.net done "one line", then c# is a continuous balancing act. The only advantage that I noted is the compactness of code that is dictated by the structure of syntactic constructions, and not something else. Eventually come to the conclusion that in 99.(9)% vb.net no less powerful language than c#. And my question is only one of the few on this topic.

Back to the question:
I looked about indexed properties, but do not understand how to implement them for the occasion I described above. Do I understand correctly that this functionality need to implement with the use of indexes?, if so, how? or I something not dug up?
by | 62 views

1 Answer

0 like 0 dislike
Completely agree with the fact that beautiful syntactic sugar in VB .NET more. And the possibility of the same, because it all eventually is compiled into the same result.
What about the properties with the options... In C#, this without dances with a tambourine there, but why not use a normal function?
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Apr 9, 2019 by sfreaky
110,608 questions
257,187 answers
0 comments
40,796 users