All Questions
18 questions
0
votes
3
answers
8k
views
Using action array vs Switch Case [closed]
I have an occasion of code in which I will draw a different set of buttons in a screen (depending on the number of the buttons).
One thought (and my current implementation) is to use an action array ...
2
votes
1
answer
918
views
Accessing a private array when I have an extension method
I'm trying to make a number of data classes for my C#/XNA game, which would essentially be a wrapper around T[,]:
public interface IGrid<T>
where T : struct
{
Point Size { get; }
T ...
-2
votes
1
answer
2k
views
C# is fantastic, if only List 'd respect Remove&Return [closed]
In the domain of system-modeling (e, systemVerilog, matlab, phyton), lists are obsoleting arrays, stacks and queues(*) altogether. Other domains that use python, perl and ruby have that same mindset, ...
1
vote
0
answers
42
views
is it better to have tracking fields that are maintained separately for arrays? [duplicate]
I wasn't sure exactly how to word this question, but basically, I have a struct stNeuralLayers (for a neural network I'm playing around with) with fields that are matrices (such as a double[,] ...
17
votes
4
answers
6k
views
size_t or int for dimensions, index, etc
In C++, size_t (or, more correctly T::size_type which is "usually" size_t; i.e., a unsigned type) is used as the return value for size(), the argument to operator[], etc. (see std::vector, et. al.)
...
2
votes
2
answers
558
views
.Net speed vs Custom Code speed
In an int?[] garunteed to have original values, I wanted to find the index of null, which will only be a single index.
I drilled into the Array.IndexOf(T[] array, T value) .NET and, after all of the ...
8
votes
2
answers
6k
views
CA1819: Properties should not return arrays. Does this happen only with arrays? If yes, why?
I have a question about CA1819 msdn performance warning.
The rule is: Arrays returned by properties are not write-protected, even if the property is read-only. To keep the array tamper-proof, the ...
2
votes
3
answers
3k
views
Building a simple AI for Noughts & Crosses game
I'm developing a simple noughts & crosses game where the player plays against the computer.
Obviously, I use the Randomize function of the language, however, the final stage of refinement is to ...
22
votes
3
answers
85k
views
Should I use a list or an array?
I'm working on a windows form to calculate UPC for item numbers.
I successfully create one that will handle one item number/UPC at a time, now I want to expand and do it for multiple item numbers/...
1
vote
4
answers
4k
views
immutable string in array, reference type vs value type
Trying to understand strings better in C#
Are these assertions correct?
string is immutable
string is reference type but behaves like value type
For these code samples...
string x = "one"
(...
1
vote
0
answers
630
views
Given a two-dimensional array what is there a good way to identify distinct regions of elements?
I am generating a 2D "world map" in Unity which I use C# and Perlin noise for.
I have a Tile object that holds the graphic of the tile and position. There are a few more attributes to this class, ...
2
votes
1
answer
1k
views
Beginners C# question about Array.Reverse
I am sitting through a very well-explained and thorough video tutorial series, using Visual Studio 2012 as my developing environment.
Anyway, one thing that is hard to figure out is this. Say you ...
55
votes
5
answers
206k
views
What's the use of .Any() in a C# List<>?
I've been discussing this with colleagues, and we couldn't figure out what the use is of .Any for any given List<>, in C#.
You can check the validity of an element in the array like the ...
0
votes
2
answers
1k
views
Check all "lines" in an array?
I have a 3D array with booleans and I need to check if there are "lines" that all contain true or false. With lines I mean horizontally, vertically and diagonally within the array. However I only need ...
4
votes
2
answers
3k
views
Data structure for grid with negative indeces
Sorry if this is an insultingly obvious concept, but it's something I haven't done before and I've been unable to find any material discussing the best way to approach it.
I'm wondering what's the ...