tagged [initialization]

Initializing a string array in a method call as a parameter in C#

Initializing a string array in a method call as a parameter in C# If I have a method like this: Why can't I call it like this? What would be the correct (but hopefully not the long way)?

13 Sep at 00:6

initializing a boolean array in java

initializing a boolean array in java I have this code could someone tell me what exactly i'm doing wrong here and how would i correct it? I just need to initialize all the array elements to Boolean fa...

2 Mar at 16:45

c++ string array initialization

c++ string array initialization I know I can do this in C++: But is there anyway to delcare an array this way without delcaring `string s[]`? e.g.

17 Aug at 11:16

Initializing a struct to 0

Initializing a struct to 0 If I have a struct like this: What would be the easiest way to initialize this struct to 0? Would the following suffice? or Would I need to explicitly init each member to 0?

3 Sep at 09:4

Setting properties via object initialization or not : Any difference ?

Setting properties via object initialization or not : Any difference ? Here's a simple question : Is there any (performance) difference between this : and this You can imagine bigger object with more ...

Difference initializing static variable inline or in static constructor in C#

Difference initializing static variable inline or in static constructor in C# I would like to know what is the difference between initializing a static member inline as in: or initializing it inside t...

Noninitialized variable in C#

Noninitialized variable in C# I have the following piece of code: Code gurus will already see that this gives an error. might not be initialized before the statement. What the value of bar? Shouldn't ...

7 Jan at 19:46

Array initialization in Perl

Array initialization in Perl How do I initialize an array to 0? I have tried this. But it always throws me a warning, . I do not know the size of the array beforehand. I fill it dynamically. I thought...

30 Sep at 11:33

Initializing a static field vs. returning a value in static property get?

Initializing a static field vs. returning a value in static property get? A) In the following code, will the method `DataTools.LoadSearchList()` only be called once, or every time the property is bein...

Can C# style object initialization be used in Java?

Can C# style object initialization be used in Java? In C# it's possible to write: I can see that array initialization can be done in a similar way but can something similar to the above be done in Jav...

14 Oct at 10:16

Assign multiple values to array in C

Assign multiple values to array in C Is there any way to do this in a condensed form? Something like `coordinates = {1.0f, ...};`?

20 Aug at 22:58

Best way to initialize (empty) array in PHP

Best way to initialize (empty) array in PHP In certain other languages (AS3 for example), it has been noted that initializing a new array is faster if done like this `var foo = []` rather than `var fo...

11 May at 15:28

Initializing strings as null vs empty string

Initializing strings as null vs empty string How would it matter if my C++ code (as shown below) has a string initialized as an empty string : vs. no/null initialization: ``` std::string myStr; ....so...

25 Apr at 05:23

What is the easiest way to initialize a std::vector with hardcoded elements?

What is the easiest way to initialize a std::vector with hardcoded elements? I can create an array and initialize it like this: How do I create a `std::vector` and initialize it similarly elegant? The...

4 Mar at 14:16

How to work out 1D array If I can't predict its length?

How to work out 1D array If I can't predict its length? ### Duplicate > [Array of Unknown Length in C#](https://stackoverflow.com/questions/599369/array-of-an-unknown-length-in-c) How do I initialize ...

20 Jun at 09:12

How to perform struct inline initialization in C#?

How to perform struct inline initialization in C#? What member should I implement in my arbitrary structure to make the following assignment possible: ``` public struct MyStruct { String s; Int leng...

4 Nov at 14:49

Why can I initialize a List like an array in C#?

Why can I initialize a List like an array in C#? Today I was surprised to find that in C# I can do: Why can I do this? What constructor is called? How can I do this with my own classes? I know that th...

13 Jan at 20:26

How to initialize private static members in C++?

How to initialize private static members in C++? What is the best way to initialize a private, static data member in C++? I tried this in my header file, but it gives me weird linker errors: I'm guess...

20 Mar at 21:27

When initializing in C# constructors what's better: initializer lists or assignment?

When initializing in C# constructors what's better: initializer lists or assignment? Class A uses an initializer list to set the member to the paramter value, while Class B uses assignment within the ...

How can I initialize a String array with length 0 in Java?

How can I initialize a String array with length 0 in Java? The Java Docs for the method `String[] java.io.File.list(FilenameFilter filter)` includes this in the returns description: > The array will b...

3 Nov at 08:11

C++: Where to initialize variables in constructor

C++: Where to initialize variables in constructor > [C++ initialization lists](https://stackoverflow.com/questions/4589237/c-initialization-lists) What are the pros/cons of initializing variables at...

23 May at 11:47

Initialize/reset struct to zero/null

Initialize/reset struct to zero/null I am filling this struct and then using the values. On the next iteration, I want to reset all the fields to `0` or `null` before I start reusing it. How can I do ...

6 Feb at 06:41

Declare and assign multiple string variables at the same time

Declare and assign multiple string variables at the same time I'm declaring some strings that are empty, so it won't throw errors later on. I've read that this was the proper way: ``` string Camnr = K...

DateTime "null" / uninitialized value?

DateTime "null" / uninitialized value? How do you deal with a DateTime that should be able to contain an uninitialized value (equivalent to null)? I have a class which might have a DateTime property v...

12 Feb at 18:5

Initialize dictionary at declaration using PowerShell

Initialize dictionary at declaration using PowerShell Given this powershell code: Is it possible to initialize this dictionary directly without having to call the Add method. Like .NET allows you to d...