Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the function of the SizeConst of the array of MarshalAs

Shulou Source: shulou.com Published: 2022-06-03 05:48:01 11月17日 Update

This article mainly introduces "what is the function of the SizeConst of the array of MarshalAs". In the daily operation, I believe that many people have doubts about the role of the SizeConst of the array of MarshalAs. The editor consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the question of "what is the use of the SizeConst of the array of MarshalAs?" Next, please follow the editor to study!

[StructLayout (LayoutKind.Sequential)] class CLS {public int id; public float value; [MarshalAs (UnmanagedType.ByValArray,SizeConst=10,ArraySubType=UnmanagedType.Struct)] public Point [] ps; [MarshalAs (UnmanagedType.LPStr)] public string msg; [MarshalAs (UnmanagedType.ByValArray,SizeConst=5,ArraySubType=UnmanagedType.LPStr)] public string [] msgs } Console.WriteLine ("Number of bytes needed by a CLS object: {0}", Marshal.SizeOf (typeof (CLS); CLS cls = new CLS (); string [] s = new string [10]; for (int I = 0 X I < 10 x I +) {s [I] = "demo" + I;} cls.msgs = s For (int iTuno Bandi)

Tags: Size array function learning reality pointer more space problem help conjecture utility clarity necessity and then this is not in general that is that is code Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information macOS Microsoft Redmi Xiaomi