Part 81 When to use a dictionary over list in c#
HTML-код
- Опубликовано: 19 сен 2024
- Text version of the video
csharp-video-tu...
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our RUclips channel. Hope you can help.
/ @aarvikitchen5572
Slides
csharp-video-tu...
Link for all csharp, asp.net, ado.net, dotnet basics, mvc and sql server video tutorial playlists
/ kudvenkat
Find() method of the List class loops thru each object in the list until a match is found. So, if you want to lookup a value using a key dictionary is better for performance over list. So, use dictionary when you know the collection will be primarily used for lookups.
I feel like once you went into making the form with the html the video went to another planet...
Write ado.net code to retrieve data from the database, and use a foreach loop to iterate thru each item and create Country object and add it to the list, and then you can use the list in the same fashion as hard coded data.
Thank you for making this tutorial series I have referenced it many times!
Thank You KudVenKad , I have learnt a lot from your videos . Regards
Dear Abobakr, thank you very much for sharing the videos. Good Luck. Venkat.
kudvenkat of all , thank you
God pleased U sir Venkat for ur efforts,i shared ur videos in my community to learn every body.
excellent video - many thanks!
Hello Venkat,
I want to thank you very much for all your videos that you posted here in youtube, it helps me alot to understand basic concepts of programing languages. It would be very grateful if you would post some AJAX videos, because it is very complex programming language and better teacher than you I have not seen anywhere! Please i beg you ;(
Sure Jeewan, there a few concepts left in generics as soon as I cam done with them we will resume with MVC.
thank you for this type of teaching. please make this type of video on MVC please!!!
Sir I have been experiencing difficulties in learning ajax and Json posting in MVC. I hope your explanation can help me understand it easily. Please continue the MVC Series.
Best Teacher.
you are awsome thank you for all the work!!!
sir great video for bigineers like us thanks for teaching us so perfectly (Y)
wtf is bigineers ?
You saved my life
why the lookup time of dictionary is less than that of List? Is there any different internal lookup techniques for List and Dictionary ?
In dictionary we provide keys which is equal to address (Not Exactly Address) so finding something with address easy than going each and every member in the list.
(Please let me know if I am wrong or is there something else I should know)
Thank you!
Thank you so much you a very good teacher but one thing im starting asp and i dont have that in my visual basic where can i download it? please i could really use the help :p
In real time MVC application to connect database, should use a connectionstring or ADO.NET entity data model ?
Is Dictionary that efficient? I mean, Dictionary needs to iterate 2 times for the same key: one for the ContainsKey method, and the second one for returning the actual object.
i think in dictionary its iterates through a string and on list it iterates through the CustomType
Both of the approaches, should have a connection string. When we use ADO.NET entity data model, connection string is auto generated for us and is stored in the web.config file. Hope this answers your question. In the description of this video, I have included the link for ASP .NET, C#, and SQL Server playlists. All the videos are arranged in logical sequence in these playlists, which could be useful to you. Please share the link with your friends who you think would also benefit from them.
Can you show any examples how to store one collection in another please
Thank you :)
Consider for example if there are two countries with same name .will dictionary return two record ? What is the correct way to implement this -a list,dictionary ,collection ,arraylist ,dictionary with array ? Please guide.
hi venkat,
here manually data is created ,suppose if data is in db ie code,country name and capita are in db, then how to compare....thanks in advance
Can you please ans following question
What is difference between dictionary and hashtable (object)?
Visual Studo 2015, Web Form project with some autogenerated parts (Default.aspx and so on)... How can I run/debug my newly added WebForm? Right click on the code, Run in browser - then VS does not recognize that it is running, and breakpoints do not work.
is it possible somehow and if it's yes how to add all objects in dictionary with loop?
I mean what if we have 1000 objects like here or in database...then we must write :
Dictionary dictionaryCountries = new Dictionary();
dictionaryCountries.Add(country1.Code, country1);
.
.
.
dictionaryCountries.Add(country1000.Code, country1000);
What if countrycode is multiple.
But doesn't the ContainsKey method of the dictionary iterate through the keys anyway? In that case we wouldn't really avoid iteration, right?
Only a string value. Not something like (object.name == "userInput"). So its still faster.
But for looking things up its way faster. The name "Dictionary" explains it.
Can I have a dictionary that can fetch data based on more than two or three fields?
Cobsider case for example if I have two countries with same name.will dictionary return two records ? What changes needs to be done ? Is there any other way to achieve this ?
no because each country is identified by a unique key. in this case the country code
Key is the unique part in dictionary and value can be duplicate
You can use dictionaryCountries.TryGetValue(strCountryCode, out Country outCountry);
Hi Arta, sure will record and upload AJAX videos as soon as I can. In the description of this video, I have included the link for ASP .NET, C#, and SQL Server playlists. All the videos are arranged in logical sequence in these playlists, which could be useful to you. Please share the link with your friends. If you like these videos, please click on the THUMBS UP button below the video. For email alerts, when new videos are uploaded, you may subscribe to my channel.
What is performance compared to this implementation?
Country resultCountry = dictionaryCountries.FirstOrDefault(ctry => ctry.Key == strCountryCode).Value;
is Country resultCountry = dictionaryCountries.ContainsKey(strCountryCode) ? dictionaryCountries[strCountryCode] : null;
better?
U started building Web form without providing its tutorials in c# series.. Content is good but this is now bouncing over the head.. 😑
how mush information is coded into genius brain
visual studio*
Country resultCountry = dictionaryCountries.ContainsKey(TextBox1.Text.ToUpper()) ? dictionaryCountries(TextBox1.Text.ToUpper()) : null;
i m getting error on this line
method name expected.....
i cant understand...plz help ....anyone here
You should use square brackets
Country resultCountry = dictionaryCountries.ContainsKey(TextBox1.Text.ToUpper()) ? dictionaryCountries[TextBox1.Text.ToUpper()] : null;
Thank you very much for taking time to give feedback. In the description of this video, I have included the link for ASP .NET, C#, and SQL Server playlists. All the videos are arranged in logical sequence in these playlists, which could be useful to you. Please share the link with your friends who you think would also benefit from them. If you like these videos, please click on the THUMBS UP button below the video. For email alerts, when new videos are uploaded, you may subscribe to my channel.
Thanks for videos. Content like this isn't found anywhere free on the internet. All the way from Kenya