Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP vs .NET and To C# or VB
Message
 
To
17/05/2002 09:14:26
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00657468
Message ID:
00658180
Views:
45
Hi Ken,

>Kamal - guess I'm missing something here. I can do a "using My.Name.Space" and refer to static class methods the same way I would functions in VFP or as you seem to be describing - i.e. with no class preface. What is the difference between this and what you are saying VB does?

If we create a static method of a class the only way to access it from C# is via Class.StaticMethod(). VB .NET provides a way to bypass the class name and simply call StaticMethod().

In case of the VFPToolkit, it has 10 classes that expose static methods for all the VFP functions. Here is an example that converts a file to a string in both VB.NET and C#.
Imports VFPToolkit.strings    'strings is actually a class
Imports VFPToolkit.dialogs
Imports VFPToolkit.common

Dim lcFile, lcString As String
lcFile = GetFile()

If Not Empty(lcFile)
   lcString = FileToStr(lcFile)
End If
Here is the C# example:
using VFPToolkit;

string lcFile, lcString ;
lcFile = dialogs.GetFile();

if(!common.Empty(lcFile))
   lcString = strings.FileToStr(lcFile)   //or VFPToolkit.strings.FileToStr()
End If
In this case we had to prefix the class name such as dialogs.GetFile(). There is always intellisense, so it is not that big of a deal and C# also provide a way to specify aliases:
using vfpS = VFPToolkit.strings;
using vfpd = VFPToolkit.dialogs;
...

// from code we simply access using vfpd.GetFont()
hth,
Kamal
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform