Couple of VB.Net lines in C#
I am converting a project from VB.Net, and I have a few lines that I am unable to convert propperly.
System.Runtime.Caching.MemoryCache.Default(Me.Name)
In this line, I understand that "Me.Name" has to be "this.Name", but the error is "Non-invocable member 'System.Runtime.Caching.MemoryCache.Default' cannot be used like a method.".
I have correctly added System.Runtime.Caching to References
Also开发者_运维技巧 return new string[];
. I have no idea how to convert this.
Thanks in advance,
RenéIt appears you want to call an indexer (sometimes called the Item
property). C# uses square-brackets []
for this purpose.
System.Runtime.Caching.MemoryCache.Default[this.Name]
I would suggest two other changes:
- If there's no ambiguity, you can leave out the
this.
- With the appropriate using directive (
using System.Runtime.Caching;
), the type doesn't have to be fully qualified.
MemoryCache.Default[Name]
精彩评论