Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Multi-dimensional vs. Jagged Arrays#450

nooelan started this conversation inIdeas
Discussion options

My model contains data that are multi-dimensional, and my first attempt was to implement this as a regular C# multidimensional array similar to this:

object[,] matrix3x3 = new object[3,3];

When trying to access this type of object from a template, Handlebars.Net threw an exception complaining it could not convert from object[ , ] to object[].

Then I changed my model implementation to jagged arrays (similar to this):

object[][] matrix3x3 = new object[3]; for (row = 0; row < 3; ++row)    matrix3x3[row] = new object[3];

This works just fine with Handlebars.Net.

Question: Is the lack of support for regular multidimensional arrays intentional, or is it a missing feature or bug?

As regular, multidimensional arrays are more efficient, at least for 2D arrays according to C# guidelines, I think it is a good idea to add support for it. It will also help avoid having to change the implementation of an already existing model.

You must be logged in to vote

Replies: 1 comment

Comment options

Hello@nooelan
Hamdlebars.Net is trying to keep feature parity with Handlebarsjs. Unfortunately multidimensional arrays are not supported in JavaScript and as a result would be never supported in Handlebarsjs.

You can provide your customObjectDescriptor that supports multidimensional arrays. However, you'd be only able to virtually project values to jagged array due to syntax limitations. Then usage will be something like this:

Value at [2,2]:{{array.2.2}}

Note:[1] is not an indexer syntax. It's rather way to specify non-valid entries (like words separated byspace) in a correct way.

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Ideas
Labels
None yet
2 participants
@nooelan@oformaniuk

[8]ページ先頭

©2009-2025 Movatter.jp