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.

Комментарии • 51

  • @CHBY
    @CHBY 5 лет назад +13

    I feel like once you went into making the form with the html the video went to another planet...

  • @Csharp-video-tutorialsBlogspot
    @Csharp-video-tutorialsBlogspot  11 лет назад +4

    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.

  • @attckDog
    @attckDog 9 лет назад +2

    Thank you for making this tutorial series I have referenced it many times!

  • @Saebnoori
    @Saebnoori 8 лет назад +1

    Thank You KudVenKad , I have learnt a lot from your videos . Regards

  • @Csharp-video-tutorialsBlogspot
    @Csharp-video-tutorialsBlogspot  11 лет назад

    Dear Abobakr, thank you very much for sharing the videos. Good Luck. Venkat.

  • @mustafaabbas2520
    @mustafaabbas2520 11 лет назад

    God pleased U sir Venkat for ur efforts,i shared ur videos in my community to learn every body.

  • @ksam8521
    @ksam8521 8 лет назад +2

    excellent video - many thanks!

  • @Rembala
    @Rembala 11 лет назад +1

    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 ;(

  • @Csharp-video-tutorialsBlogspot
    @Csharp-video-tutorialsBlogspot  11 лет назад

    Sure Jeewan, there a few concepts left in generics as soon as I cam done with them we will resume with MVC.

  • @karishmapatil3020
    @karishmapatil3020 6 лет назад

    thank you for this type of teaching. please make this type of video on MVC please!!!

  • @jeewanmaharjan2712
    @jeewanmaharjan2712 11 лет назад

    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.

  • @solutions9991
    @solutions9991 5 лет назад

    Best Teacher.

  • @MrYudi770
    @MrYudi770 7 лет назад

    you are awsome thank you for all the work!!!

  • @hassaankhan786
    @hassaankhan786 11 лет назад

    sir great video for bigineers like us thanks for teaching us so perfectly (Y)

    • @mandinh18
      @mandinh18 3 года назад

      wtf is bigineers ?

  • @gabrieladaconceicaodias4113
    @gabrieladaconceicaodias4113 4 года назад

    You saved my life

  • @kunalkp12345
    @kunalkp12345 9 лет назад +3

    why the lookup time of dictionary is less than that of List? Is there any different internal lookup techniques for List and Dictionary ?

    • @vinaykumar3196
      @vinaykumar3196 6 лет назад +3

      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!

  • @gian-lucanardini9706
    @gian-lucanardini9706 9 лет назад +1

    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

  • @truptibet7656
    @truptibet7656 11 лет назад

    In real time MVC application to connect database, should use a connectionstring or ADO.NET entity data model ?

  • @LeoTchobanian
    @LeoTchobanian 5 лет назад +1

    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.

    • @zeroone8548
      @zeroone8548 4 года назад

      i think in dictionary its iterates through a string and on list it iterates through the CustomType

  • @Csharp-video-tutorialsBlogspot
    @Csharp-video-tutorialsBlogspot  11 лет назад +1

    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.

  • @krishramakrishna9567
    @krishramakrishna9567 2 месяца назад

    Can you show any examples how to store one collection in another please

  • @ivandrofly
    @ivandrofly 11 лет назад

    Thank you :)

  • @web3.0_metaverse_XR
    @web3.0_metaverse_XR 6 лет назад

    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.

  • @harikaaakutota7776
    @harikaaakutota7776 11 лет назад

    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

  • @shraddhakotadia5515
    @shraddhakotadia5515 5 лет назад

    Can you please ans following question
    What is difference between dictionary and hashtable (object)?

  • @Trzbne
    @Trzbne 6 лет назад

    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.

  • @gregorym7598
    @gregorym7598 4 года назад

    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);

  • @saurabhkatrojwar2290
    @saurabhkatrojwar2290 2 года назад +1

    What if countrycode is multiple.

  • @paulsavage6095
    @paulsavage6095 8 лет назад

    But doesn't the ContainsKey method of the dictionary iterate through the keys anyway? In that case we wouldn't really avoid iteration, right?

    • @nameStringEmpty
      @nameStringEmpty 8 лет назад

      Only a string value. Not something like (object.name == "userInput"). So its still faster.

    • @FirstLast-ws7zw
      @FirstLast-ws7zw 8 лет назад

      But for looking things up its way faster. The name "Dictionary" explains it.

  • @NimishP
    @NimishP 2 года назад

    Can I have a dictionary that can fetch data based on more than two or three fields?

  • @web3.0_metaverse_XR
    @web3.0_metaverse_XR 6 лет назад

    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 ?

    • @joeyjoejoo
      @joeyjoejoo 5 лет назад +1

      no because each country is identified by a unique key. in this case the country code

    • @kushagrakhandelwal8867
      @kushagrakhandelwal8867 3 года назад +1

      Key is the unique part in dictionary and value can be duplicate

  • @AbdelRahmanSeyamEg
    @AbdelRahmanSeyamEg 5 лет назад

    You can use dictionaryCountries.TryGetValue(strCountryCode, out Country outCountry);

  • @Csharp-video-tutorialsBlogspot
    @Csharp-video-tutorialsBlogspot  11 лет назад +1

    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.

  • @jayem7001
    @jayem7001 6 лет назад

    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?

  • @tabrezhasan4272
    @tabrezhasan4272 6 лет назад +2

    U started building Web form without providing its tutorials in c# series.. Content is good but this is now bouncing over the head.. 😑

  • @lifet4800
    @lifet4800 8 лет назад

    how mush information is coded into genius brain

  • @gian-lucanardini9706
    @gian-lucanardini9706 9 лет назад +1

    visual studio*

  • @kavithavishwanathen6778
    @kavithavishwanathen6778 8 лет назад

    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

    • @sergeycherniavsky2289
      @sergeycherniavsky2289 7 лет назад

      You should use square brackets
      Country resultCountry = dictionaryCountries.ContainsKey(TextBox1.Text.ToUpper()) ? dictionaryCountries[TextBox1.Text.ToUpper()] : null;

  • @Csharp-video-tutorialsBlogspot
    @Csharp-video-tutorialsBlogspot  11 лет назад +2

    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.

    • @martinnjoroge9789
      @martinnjoroge9789 5 лет назад

      Thanks for videos. Content like this isn't found anywhere free on the internet. All the way from Kenya