Byte array
sanoj
Member Posts: 19
Hi
I am using the new Dotnet datatype and I'm trying to rewrite the following c# code in c/al, but can't figure out how...
How do I write this in c/al?
Br, Jonas
I am using the new Dotnet datatype and I'm trying to rewrite the following c# code in c/al, but can't figure out how...
int buffLength = 2048; byte[] buff = new byte[buffLength];
How do I write this in c/al?
Br, Jonas
0
Comments
-
As from what i know, you can't use dotnet datatypes directly, so you can't create a byte array.
EDIT:
But since System.Byte is mapped to the C/AL Datatype Char you could make a char array of the size you need and use that one? (Not tested)
http://msdn.microsoft.com/en-us/library/gg502522.aspx0 -
there's also a WONDERFUL, OUTSTANDING session by vjekoslav babic, done at the navtechdays that explains a lot of things (array and CAL/.NET datatype mapping included).
you can download it here
http://www.mibuso.com/dlinfo.asp?FileID=13990 -
Hi,
Thanks for your replies. After looking at the video ( great by the way ) I figured out how to do it. I used the wrapper.
Sorry that Microsoft hasn't provided us with these wrappers in NAV... In my opinion, one great thing about the Dotnet interop is that you don't have to distribute a lot of dll:s. But to handle this, you have to distribute the wrapper...
Br, Jonas0 -
I know this is quite old but this is how I did it...
Two Variables:
Name DataType Subtype
NETArray DotNet System.Array.'mscorlib, Version=4.0.0.0, Culture=neutral,...
NETType DotNet System.Type.'mscorlib, Version=4.0.0.0, Culture=neutral,...
In C/AL:
NETType := NETType.GetType('System.Byte',FALSE);
NETArray := NETArray.CreateInstance(NETType, NETConvert.FromBase64String(BigString).Length);
NOTE: NETConvert was another DotNet variable for Encoding.
NETArray is now your byte array and you can write to it. The only downfall I've found is the fact that you have to create an instance knowing the length up front. So for me I had to 'getbytes' twice...but at least it keeps everything in C/AL.1
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions