Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make Delphi Prism indexed properties visible to C# when properties are not default
    text
    copied!<p>I have several Delphi Prism classes with indexed properties that I use a lot on my C# web applications (we are migrating a big Delphi Win32 system to ASP.Net). My problem is that it seems that C# can't see the indexed properties if they aren't the default properties of their classes. Maybe I'm doing something wrong, but I'm completely lost.</p> <p>I know that this question looks a lot like a bug report, but I need to know if someone else knows how to solve this before I report a bug.</p> <p>If I have a class like this:</p> <pre><code>TMyClass = public class private ... method get_IndexedBool(index: Integer): boolean; method set_IndexedBool(index: Integer; value: boolean); public property IndexedBool[index: Integer]: boolean read get_IndexedBool write set_IndexedBool; default; // make IndexedBool the default property end; </code></pre> <p>I can use this class in C# like this:</p> <pre><code>var myObj = new TMyClass(); myObj[0] = true; </code></pre> <p>However, if TMyClass is defined like this:</p> <pre><code>TMyClass = public class private ... method get_IndexedBool(index: Integer): boolean; method set_IndexedBool(index: Integer; value: boolean); public property IndexedBool[index: Integer]: boolean read get_IndexedBool write set_IndexedBool; // IndexedBool is not the default property anymore end; </code></pre> <p>Then the IndexedBool property becomes invisible in C#. The only way I can use it is doing this:</p> <pre><code>var myObj = new TMyClass(); myObj.set_IndexedBool(0, true); </code></pre> <p>I don't know if I'm missing something, but I can't see the IndexedBool property if I remove the <i>default</i> in the property declaration. Besides that, I'm pretty sure that it is wrong to have direct access to a private method of a class instance.</p> <p>Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload