© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
23 replies
morry329#

❔ ✅ IndexOutOfRangeException

I just tried to code out a simple app that reads a .csv file (as per screenshot) and displays the content in the columns "state" and "city" . My Main points out an IndexOutOfRangeException, so something is out of the range. But I am lost to find it out now.

static void Main(string[] args)
        {
            var codeSearch = new ZIPCodeSearch();
            codeSearch.Build(new StreamReader(args[0], Encoding.Default)); //ERROR HERE
            
            Console.WriteLine($"Anwendung ZIPCodeSearch");

            string value;
            while ((value = Console.ReadLine()) != "")
            {
                var scanned = codeSearch.Classify(value);
                Console.WriteLine($"Stadt: {codeSearch.Classify(value)} unbekannt");
                Console.WriteLine($"Land:{codeSearch.Classify(value)}");
            }
        }
static void Main(string[] args)
        {
            var codeSearch = new ZIPCodeSearch();
            codeSearch.Build(new StreamReader(args[0], Encoding.Default)); //ERROR HERE
            
            Console.WriteLine($"Anwendung ZIPCodeSearch");

            string value;
            while ((value = Console.ReadLine()) != "")
            {
                var scanned = codeSearch.Classify(value);
                Console.WriteLine($"Stadt: {codeSearch.Classify(value)} unbekannt");
                Console.WriteLine($"Land:{codeSearch.Classify(value)}");
            }
        }


Could anyone point me in the right direction?
My other classes for this project is here - FYI:
https://github.com/morry239/HashTableRedBook/blob/master/ZIPCodeSearch/ZIPCodeSearch.cs
Bildschirmfoto_2023-02-20_um_17.40.44.png
GitHub
HashTableRedBook/ZIPCodeSearch.cs at master · morry239/HashTableRed...
Contribute to morry239/HashTableRedBook development by creating an account on GitHub.
HashTableRedBook/ZIPCodeSearch.cs at master · morry239/HashTableRed...
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

✅ System.IndexOutOfRangeException
C#CC# / help
2y ago
IndexOutOfRangeException? Why??
C#CC# / help
2y ago
Levenshtein distance method throwing `IndexOutOfRangeException` [Answered]
C#CC# / help
4y ago
❔ System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'
C#CC# / help
3y ago