CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    May 2009
    Posts
    34

    Baffled by Structures

    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.

    What am I doing wrong?

    I've attached the MSFL.cs file.

    Thanks.

    Webbiz
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured