Hi I have writen an Nested Structure in C# . Find the code snippet below:
public struct SMB_MESSAGE
        {
            #region SMB Parameter
            public struct SMB_PARAMETERS
            {
                public byte WordCount;
                public ushort[] Words;
            }
            #endregion
            #region SMB Data
            public struct SMB_DATA
            {
                public ushort ByteCount;
                public struct Bytes
                {
                    public ushort BufferFormat;
                    public byte[] Name;
                }
            }
            #endregion
        }
Now While I assign the Value to the the Inner structure as below:
SMB_MESSAGE SMBMESSAGE;
SMB_MESSAGE.SMB_PARAMETERS SMBPARAMETER;
SMBPARAMETER.WordCount=12;
SMBPARAMETER.Words=null;
SMB_MESSAGE.SMB_DATA SMBDATA;
SMBDATA.ByteCount=byteCount;
SMB_MESSAGE.SMB_DATA.Bytes bytes;
bytes.BufferForma开发者_运维知识库t=bFormat;
bytes.Name=name;
Now When I look into the value of SMBMESSAGE while debugging it shows NameSpace.Form1.SMB_MESSAGE and no values inside it. I can't also see a way to asign the values to SMBMESSAGE .
Your two inner structs are nested types, not instance members.
Nested types have no effect on instances of the parent types; they are a purely organizational concept (except that they can access the parent type's private members)
Therefore, your SMB_MESSAGE struct doesn't actually have any instance members.
You need to make four normal structs, then make two properties in SMB_MESSAGE holding the other two structures.
For example:
public struct SMB_MESSAGE {
    public SMB_PARAMETERS Parameters;
    public SMB_DATA Data;
}
public struct SMB_PARAMETERS
{
    public byte WordCount;
    public ushort[] Words;
}
public struct SMB_DATA
{
    public ushort ByteCount;
    public Bytes Bytes;
}
public struct Bytes
{
    public ushort BufferFormat;
    public byte[] Name;
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论