You mean:
List <string> list = new List <string> ();
list [5] = "I'm an indexed property";
Printable View
You mean:
List <string> list = new List <string> ();
list [5] = "I'm an indexed property";
perhaps some day they will be as cool as indexed properties in C++/CLI which I miss in C#, they are replaced with get_Something and set_Something methods :(
What is the difference between C++ indexed properties and C# indexed properties?Quote:
some day they will be as cool as indexed properties in C++/CLI which I miss in C#
a C# class can have only one indexed property, the "this", whereas a C++/CLI class can have multiple indexed properties that can have any name
No, that's an indexer.
I mean:
In C# that could have looked something like:Code:...
private:
array<String^>^ myNames;
public:
property String^ Name[int]
{
String^ get(int index)
{
return myNames[index];
}
void set(int index, String^ value)
{
myNames[index] = value;
}
}
...
// Usage:
String^ name = obj->Name[3];
Code:...
private String[] myNames;
public String Name[int]
{
get
{
return myNames[index];
}
set
{
myNames[index] = value;
}
}
...
// Usage:
String name = obj.Name[3];
You are right, I've edited my post!
Ah, very nice. I didn't realise that was possible in C++/CLI. I thought you were just referring to the regular indexer by a different name ;)
Ok people that bash on vb.net has not even looked into vb since the vb6 days. Those people can stay in their c# world and continue to look real dumb. C# and vb.net are almost the same. You can do almost the same things in c# and vb.net. My advice is to learn them both. Tired of hearing the old heads bash vb.net.
Also those who say vb.net code can be jumbled...did you ever look at a hugh program I c#? That is the lamest excuse ever.
Naturally in the C# area of a forum most people would say they prefer C#. If the thread was posted in the VB.Net section the answers would be a bit different.
The fact is that both are very good languages and can do many many things. Which is better depends on who you are and what you are doing. If you are a former VB or VBA coder then VB.Net is much easier to code in than C# simply because of the fact the C# is case sensitive and requires the use of ; after every line of code both of which are things that may trip up a coder who is not used to this. C# on the other hand would be easier for someone who has coded more in C/C++, Java or other similar language.
Personally I find C# code to be a bit longer and harder to follow but that is because I have only used C# and Java script on a few occasions and have been writing in different versions of VB for many years.