Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to test console application
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01349592
Message ID:
01349595
Views:
17
>>Hi everybody,
>>
>>This is actually sort of an initial interview question. I have this program
>>
>>using System;
>>
>>namespace CreditSights
>>{
>>    /// <summary>
>>    /// The purpose of this program is to read in a file and search for all
>>    /// occurrences of the string passed in. 
>>    /// 
>>    /// e.g. SearchForText.exe autonomous resume.txt
>>    /// e.g. SearchForText.exe smart resume.txt
>>    /// </summary>
>>    class SearchForText
>>    {
>>        static void Main(string[] args)
>>        {
>>            string toFind = args[1];
>>            string file = args[2];
>>
>>            string text = System.IO.File.OpenText(file).ReadToEnd();
>>
>>            Console.WriteLine("Found it at: " + text.IndexOf(toFind));
>>        }
>>    }
>>}
>>
>>And I need to figure out what is wrong with it. I created a new Console application but then I try to debug it I obviously get an error. So, my question is how to test it.
>>
>>Also in terms of what is wrong here I guess no error checking is the first thing that is wrong. But what else is wrong?
>>
>
>Besides error checking/handling, arrays in C# are zero based, so instead of args[1] and args[2] it should be args[0] and args[1].

Right, missed that. So, how should I test this in VS?

Thanks again.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform