Coming from a VB6 background, I'm trying to get a handle on VS 2010 C#.
Online, I located a file called MSFL.cs that contains structure definitions in a STATIC class container.
One of the struct definitions is the following (partial):
[StructLayout( LayoutKind.Sequential, CharSet = CharSet.Ansi )]
public static struct MSFLSecurityInfo
{
public static uint dwTotalSize; // Structure size
public static IntPtr hSecurity; // Security handle
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = MSFL_MAX_NAME_LENGTH + 1 )]
public static String szName; // Security name
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = MSFL_MAX_SYMBOL_LENGTH + 1 )]
public static String szSymbol;
. . .
I have a main .cs called MainWindow.xaml.cs (VS created) that I want to create a reference variable of type struct (MSFLSecurityInfo).
First, I tried doing this:
MSFL.MSFLSecurityInfo SecInfo = new MSFL.MSFLSecurityInfo();
Intellisense provided the dropdown lists perfectly indicating that the IDE recognized the existence of the MSFL class and the structure definitions within it.
Then I tried to assign a value to one of the fields in struct SecInfo.
SecInfo.szName = "Some string...";
Intellisense did not detect any members for SecInfo and I was unable to do anything with it.
NEXT:
Knowing that the structure definition is in a STATIC CLASS, I tried the other approach shown below.
MSFL.MSFLSecurityInfo SecInfo;
SecInfo.szName = "Some string...";
This did not work either, and intellisense did not detect struct members for SecInfo.
NEXT I DID THIS:
At the structure definition, I added the STATIC keyword to the structure name as well as the members themselves within the structure definition. Then I tried the above again and it still does not work.
I'M BAFFLED!
I would have thought that creating a structure reference of type structure that is declared in another .cs file would be a breeze.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.