-2

I'm facing an issue to convert VB.NET To C#, to be clear here is VB.NET code :

VB. NET :

  Private listFlDay As New List(Of FlowLayoutPanel)

C# :

  private List<FlowLayoutPanel> listFlDay = new List<FlowLayoutPanel>();

So far all is well, but in my code on VBA i have this method :

VB :

listFlDay((i - 1) + (startDayAtFlNumber - 1)).Tag = i 

C# :

 listFlDay((i - 1) + (startDayAtFlNumber - 1)).Tag = i;  

but i have an error like : listFlDay cannot be used as a method in C#

Can you please told me how i can convert this to C# ?

Thank you

Kamal

kamal
  • 9
  • 5
  • You don't need to put the type on both sides of the = in modern C# `private List listFlDay = new();` will be fine – Caius Jard Aug 22 '21 at 06:28

1 Answers1

1

but in my code on VBA i have this in one methode

No you don't. listFlDay isn't a method. You just declared it as a List.

In VB you use parentheses to invoke a method but you also use them to index an array, or in this case a List. In C# you use square brackets to index an array (or List):

listFlDay[(i - 1) + (startDayAtFlNumber - 1)].Tag = i;
David
  • 208,112
  • 36
  • 198
  • 279