phalanger (PHP): calling nested static C# classes

259 views Asked by At

I cannot seem to get this to work without the compiler yelling at me for being... stupid. But I have a class with another nested static class inside of it. I am trying to access it but I get a syntax error saying:

unexpected token ::

I am trying to call the class as follows:

myLibrary\myClass::nestedClass::myFunction()

The first set to '::' work just fine but the second pair are causing an error. Any idea of how I approach this? A lot of my libraries are written this way and I would very much appreciate if someone could help me!

1

There are 1 answers

1
Serguei Fedorov On BEST ANSWER

There is actually a solution to this. Silly me! In order to get the nested class out of the class, its really simple. Look at how you can get a DataTable class out of the System .NET class:

  System\Data\DataTable

the same can be done with your library. For the code I have posted above, simply do:

  myLibrary\myClass\nestedClass::myFunction()

I replaced the first :: with a \ This way the compiler knows what I am looking for! Thanks for the suggestions, all of them would work wonderfully, in fact maybe are a little better code practice wise!