About 27,300,000 results
Open links in new tab
  1. What does `array[^1]` mean in C# compiler? - Stack Overflow

    Oct 26, 2020 · Also, it's obviously better than using numbers.Count()-1 since Count() is a Linq method that needs to iterate through the entire array. – Camilo Terevinto Commented Oct 26, 2020 at 10:00

  2. How do I declare and initialize an array in Java? - Stack Overflow

    Jul 29, 2009 · Static Array: Fixed size array (its size should be declared at the start and can not be changed later) Dynamic Array: No size limit is considered for this. (Pure dynamic arrays do not exist in Java. Instead, List is most encouraged.) To declare a static array of Integer, string, float, etc., use the below declaration and initialization statements.

  3. How to create an array containing 1...N - Stack Overflow

    This is probably the fastest way to generate an array of numbers. Shortest. var a=[],b=N;while(b--)a[b]=b+1;

  4. How to declare Array variable in SQL Server? - Stack Overflow

    Jan 16, 2017 · As others said in this post, there's no array type because of the natural behavior of a DB and because of that there's no for or foreach, but there are tables and they could work kinda the same. First you'll declare a variable as a table: DECLARE @TempTable TABLE ([Id] INT) Then you'll insert the respective Ids as you want

  5. Check if an element is present in an array [duplicate]

    function isInArray(value, array) { return array.indexOf(value) > -1; } Execution: isInArray(1, [1,2,3]); // true Update (2017): In modern browsers which follow the ECMAScript 2016 (ES7) standard, you can use the function Array.prototype.includes, which makes it way more easier to check if an item is present in an array:

  6. Adding values to a C# array - Stack Overflow

    Oct 15, 2008 · //the array you want to fill values in string[] arrayToBeFilled; //list of values that you want to fill inside an array List<string> listToFill = new List<string> { "a1", "a2", "a3" }; //looping through list to start filling the array foreach (string str in listToFill){ // here are the LINQ extensions arrayToBeFilled= arrayToBeFilled.Append(str ...

  7. How can I add new array elements at the beginning of an array in ...

    Actually, all unshift/push and shift/pop mutate the source array. The unshift/push add an item to the existed array from begin/end and shift/pop remove an item from the beginning/end of an array. But there are few ways to add items to an array without a mutation. the result is a new array, to add to the end of array use below code:

  8. Initialising an array of fixed size in Python - Stack Overflow

    One thing to note: all elements in the list will have initially the same id (or memory address). When you change any element later on in the code, this will impact only the specified value, - HOWEVER - if you create a list of custom objects in this way (using the int multiplier) and later on you change any property of the custom object, this will change ALL the objects in the list.

  9. How to add a string to a string [] array? There's no .Add function

    If you really want an array at the end, use. myCollection.ToArray(); You might be better off abstracting to an interface, such as IEnumerable, then just returning the collection. Edit: If you must use an array, you can preallocate it to the right size (i.e. the number of FileInfo you have). Then, in the foreach loop, maintain a counter for the ...

  10. Which comes first in a 2D array, rows or columns?

    Jul 25, 2012 · +1 for expressing contrast of ARRAY vs MATRIX! Arrays have no geometric definition. If you think a 1D array is vertical then row is first, if you think a 1D array is horizontal then col is first. When using a rectangular 2D array there is no logical distinction, as long as you keep it the same throughout your code. IMPLEMENT ACCORDING TO YOUR ...