[Solved] C++ vector v, vector*v, vector vec, which is the fastest (or the most efficient)? [closed]

There is a big misunderstanding here: You are comparing vectors with different semantics. It’s like asking which is faster, a glass of water or a banana. If you think about using a vector of pointers, std::vector<T*>, you need to be aware that you are using manual memory management. It might be faster in some use-cases, … Read more

[Solved] C# async and await keywords not working as expected with property getter [duplicate]

When the compiler encounters await keyword it will automatically schedule a task in task scheduler. The operation waits (in a non-blocking manner) for the task to complete before continue to do the rest of the code block. To make your code run in parallel you need to modify it into public async Task GetDistance() { … Read more

[Solved] For a concurrent download handler does this create a race condition?

As you can tell from some of the comments, multithreaded code is serious business. It’s best to follow a proven pattern, e.g. producer-consumer, or at least use an established synchronization primitive like a monitor or semaphore. Because I might be wrong. It is easy to go over code that you came up with yourself and … Read more

[Solved] How to Convert int into char string

What? A character is typically just that, one character. Not seven. You can do a wide character: char what=”12-4-30″; but I think that’s more bits than most compilers will let you have in a char, so it’s not going to work. If you meant a string of character, you should use snprintf(): char what[32]; snprintf(what, … Read more

[Solved] OpenMP – simplest accumulator in loops gives incorrect result

You’ve programmed a canonical data-race. All the threads in your program are contending to update the variable count and there are no guarantees about the order in which each thread reads, updates, then writes the values to the variable. Whatever you may believe C++ does not guarantee that ++ is applied atomically. You should read … Read more

[Solved] Why method call on class level always expect static parameter?

It doesn’t “expect static” anything – simply: you aren’t allowed to access this at this point, and number is implicitly this.number. Move the code to a constructor instead: public Foo() { number = “13”; a = Convert.ToString(number); } string number; int a; 2 solved Why method call on class level always expect static parameter?

[Solved] Display byte array in textbox [closed]

The equivalent C# of your last line is: TextBox1.Text = String.Join(“”, Array.ConvertAll(bArr, byteValue => byteValue.ToString())); You replace the anonymous function with a lambda expression (byteValue => byteValue.ToString()) As I noted in my comment, this will print the decimal values of the bytes, so 0x00 will be printed as 1, and 0xFF will be printed as … Read more

[Solved] How can i assign these “var” results to different variables? [closed]

C# is strongly typed variables must be defined at compile time, so you can not create variables dynamically at runtime. However, you can use a collection to hold your results. Using a list: var result = db.servis.Where(s => …).ToList(); // access first element: var first = result.ElementAt(0); Using an array: var result = db.servis.Where(s => … Read more

[Solved] How to save data from an array [closed]

Split problem into lesser ones: How would you like to save an item to string in a file How would you like to read (parse) an item from a string (line) of the file? in case school grades are just ints: int[] grades = new int[] {2, 3, 4, 5, 2}; the answers for the … Read more