For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
Ok, very basic to you guys but I'm hoping someone can offer some advice.
I'm making a parking lot windows forms project and have a class structure of:
Then a ParkingLot class which declares a private Dictionary collection of type <string, vehicle=""> to store all the instances. The key is a parking space code e.g. A1, A2, B1, B2 etc, which then returns the vehicle object associated with that slot in the parking lot.
I've made the dictionary private so that all of the functionality is contained in the parkinglot class and the form button presses etc only update the dictionary via public methods in that class for abstraction/separation of concerns (if that's the correct terminology!). The contents of the dictionary are currently displayed in a textbox by calling a parkinglot.displayinventory method which loops through the dictionary items and uses a stringbuilder to create and return the details of all the items to display in the textbox.
All was fine, however, now I want to change it to display the contents in a listbox rather than a text box and now I'm questioning whether using a dictionary object was a good idea (I was thinking of the efficiency of retrieval O(1) of dictionary vs O(n) of list and all that).
Should I just use a public List<vehicle> which I can then bind to the listbox? But then I thought from an abstraction point of view, having the list of items accessible from the form/view was a bad thing?? Should I stick with a private dictionary for efficient retrieval and create and return a readonlycollection object from the displayinventory method for binding (or something similar)?
It's been a while since I've worked with collections and classes and things like this and I've confused myself no end with something so simple! Any tips much appreciated
I see no fundamental difference between displaying vehicular text in a TextBox and the same in a ListBox.
You never have to use binding, but you can.
Without using any binding, you can iterate your Dictionary and build a string for each Vehicle (I'd say your Vehicle.ToString method should serve that purpose), then add that string to the ListBox.Items
Or indeed you can set up a List of Vehicles and use binding; I know I wouldn't, as I don't like creating a second collection with all the risks of getting out of sync... You could consider using Dictionary.Values as the list of items to be displayed; depends on how you handle empty spots I guess.
PS: the one advantage of using a ListBox, if your app would need that, is that you can actually paint some graphics in a ListBox item (an icon, a picture, whatever); a ListBox collects objects, they don't have to be strings! It would require you to add the actual Vehicles to the ListBox.Items, your ListBox to be set to UserDrawn mode, and you to implement a DrawItem handler.
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
So typing as little as possible help no-one - we don't even know what kind of app you are writing, so we can't give you any specific information!
Try again, this time explaining as if to someone who knows absolutely nothing about your project and is at the other end of a telephone.
Tell us what you have tried, where you are stuck, what help you need - and be specific!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
Unable to see traces and Service in Jaeger UI on host server, used C# client (tracer) for Jaeger but able see traces in local environment using "jaeger-all-in-one --collector.zipkin.http-port=9411"
I have tried below code and Referred link as
public static class JaegerTracingServiceCollectionExtensions
public static IServiceCollection AddJaegerTracing(
this IServiceCollection services,
Action<jaegertracingoptions> setupAction = null)
if (setupAction != null) services.ConfigureJaegerTracing(setupAction);
var options = cli.GetService<ioptions<jaegertracingoptions>>().Value;
var senderConfig = new Jaeger.Configuration.SenderConfiguration(options.LoggerFactory)
var reporter = new RemoteReporter.Builder()
var sampler = new GuaranteedThroughputSampler(options.SamplingRate, options.LowerBound);
var tracer = new Tracer.Builder(options.ServiceName)
// Allows code that can't use dependency injection to have access to the tracer.
I am beginner in C# and I am building an application to create a workbook (Book1.xlsx) then copy a specific sheet from another workbook ( Book2.xlsx ).
I created Book1 but I am trying to copy Sheet1 from Book2 but I could not.
before copying [Sheet1 from Book2 ] I am dong a kind of check to collect names for all opened workbooks so I could not be able to get names of workbooks which opened by Visual Studio c# by the below piece of code but If will open the same workbooks by myself I found the below code can get the name of opened workbooks without problem.
I`m working on a graphics editor. I was trying to implement a gui in DirectX but I realised that`s not the right approach. I`m used to C# Forms so I was asking myself if I can stitch C# GUI (Forms) and C++ DirectX together. Any help is welcome.
WinForms is also not the right approach. Use WPF instead.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
I need a usable license plate recognition program for my thesis. I would like to use it for entry access control. I wrote my program in C# language and the recogniser should be detect plate from images. I really appreciate any help or suggestion.
I want to detect europen plates, especially Hungarian and area.
Something you need to consider when you put strings in place using syntax like string s1 = "1,2"; or myClass.CallMethod("3,4");; these strings are interned in the string pool. In other words, the string is not garbage collected until the tests finish and the AppDomain is unloaded.
In terms of memory management they are the same. When you inline a string it still creates a string object which is stored in memory, the only difference is that it isn't assigned to a variable. Same with the int. In terms of performance, if you are in debug mode then you could argue the first version will perform worse due to the variable allocations, but we're talking single cpu cycles of difference. In release mode both of those code samples will effectively compile to the same code as the optimiser will inline the variables for you.
As for when they are deallocated, a test method is no different from any other method so the variables will be handled like normal.
the .NET String class is a reference type, correct?
Why then must I add the ref keyword to a string argument if I want its value to be updated in the called function?
No other reference type behaves this way, correct?
UPDATE: I just realized what's going on. Strings are immutable so when you pass a string with the ref keyword, it's the original reference to the string that is being updated with the new string. Without the ref keyword, the called function gets its own reference to the string, and if changes are made, then it's the function's reference that is updated, not the original reference.
The difficult we do right away...
...the impossible takes slightly longer.