Reptillian Posted September 30, 2021 Share Posted September 30, 2021 (edited) Here's the problem I have. How to add to Image_Rect list? List<(int,int,int,int,int)> Image_Rect = new List<(int,int,int,int,int)>(); Image_Rect.Add(Tuple((100,0,100,0,5))); The above don't work. What I'm trying to do is create 2 set of dynamic array of fixed size array of size 5, and to be able to access each variable at index n and to remove at index n. In addition to that, I would like to be able to use functions on it to replace the n index. Any idea? Edited September 30, 2021 by Reptillian Quote G'MIC Filter Developer Link to comment Share on other sites More sharing options...
otuncelli Posted September 30, 2021 Share Posted September 30, 2021 You need to use ValueTuple. Image_Rect.Add(new ValueTuple<int, int, int, int, int>(100, 0, 100, 0, 5)); Or using a syntactic sugar you can simply write like this: Image_Rect.Add((100, 0, 100, 0, 5)); Quote Link to comment Share on other sites More sharing options...
Reptillian Posted September 30, 2021 Author Share Posted September 30, 2021 For both, I get errors. Invalid token '(' in class, record, struct, or interface member declaration Type expected Tuple must contain at least two elements. ) expected Tuple must contain at least two elements. ) expected Invalid token '100' in class, record, struct, or interface member declaration Quote G'MIC Filter Developer Link to comment Share on other sites More sharing options...
toe_head2001 Posted September 30, 2021 Share Posted September 30, 2021 This code works for me; no errors. List<(int,int,int,int,int)> Image_Rect = new List<(int,int,int,int,int)>(); Image_Rect.Add((100,0,100,0,5)); Are you using an old version of Visual Studio? Like 2017, or even an old build of 2019? Quote June 7th, 2023: Sorry about any broken images in my posts. The underlying DNS issue should be resolved soon. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Reptillian Posted September 30, 2021 Author Share Posted September 30, 2021 2 minutes ago, toe_head2001 said: This code works for me; no errors. List<(int,int,int,int,int)> Image_Rect = new List<(int,int,int,int,int)>(); Image_Rect.Add((100,0,100,0,5)); Are you using an old version of Visual Studio? Like 2017, or even an old build of 2019? CodeLab 6.3 actually. Quote G'MIC Filter Developer Link to comment Share on other sites More sharing options...
toe_head2001 Posted October 1, 2021 Share Posted October 1, 2021 I have no issues in CodeLab either. Please post a screenshot. Quote June 7th, 2023: Sorry about any broken images in my posts. The underlying DNS issue should be resolved soon. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Reptillian Posted October 1, 2021 Author Share Posted October 1, 2021 Quote G'MIC Filter Developer Link to comment Share on other sites More sharing options...
AndrewDavid Posted October 1, 2021 Share Posted October 1, 2021 Same error here. Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted October 1, 2021 Share Posted October 1, 2021 Your code is directly in the class body. That will never work. Try putting it within a code block, such as Render() or PreRender(). Or, if it must be initialized directly in the class body for whatever reason, it can be written like this: List<(int,int,int,int,int)> Image_Rect = new List<(int,int,int,int,int)> { (100,0,100,0,5) }; 1 Quote June 7th, 2023: Sorry about any broken images in my posts. The underlying DNS issue should be resolved soon. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Reptillian Posted October 1, 2021 Author Share Posted October 1, 2021 (edited) EDIT: Never mind, I got it. Edited October 1, 2021 by Reptillian Quote G'MIC Filter Developer Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.