I am a VB.NET programmer by nature and I am having a hard time figuring this out. Any help with the following would be appreciated.
I need to get the C# code (1) below to work. The VB.NET equivalent works just fine, but the C# does not.
Note that both (2) and (3) do work, but this is actually auto-generated code, and I need the VB.NET and C# versions to be as similar as possible.
-
This does not compile (the fully-qualified name of
EngineisThreeD.QVB.Engine):using ThreeD.QVB; namespace QVBScript { public class ScriptCode { public void Main(ref Engine.QVBObjectsDictionary objects, Engine.Commands commands) { … -
However, this does work:
//using ThreeD.QVB; // I'm instead using fully-qualified names in the method namespace QVBScript { public class ScriptCode { public void Main(ref ThreeD.QVB.Engine.QVBObjectsDictionary objects, ThreeD.QVB.Engine.Commands commands) { … -
This works, too:
using eng = ThreeD.QVB.Engine; namespace QVBScript { public class ScriptCode { public void Main(ref eng.QVBObjectsDictionary objects, eng.Commands commands) { …
In VB.NET if you have an
importfor the first part of a namespace, you can reference just the later half. In C# you cannot do this. You must have ausingfor the full namespace, or fully qualify your type names. Different languages, different rules.In your last example you do not need to use the alias.