i mean in a console application when we make any program to pirnt a number 5 times then it automaically check tha errors in visual C#. but when we press E5 to buil the console application it it appears on the screen only for 1-2 second means not for enough time to see the output . what is the command in console application by which output should be visible atleast for 5 second.
you can use System.Threading.Thread.Sleep(5000); which will pause the main thread for 5 seconds before allowing the console to exit. As mentioned you could also use Console.ReadLine() but that would then require you to press enter for the console application to exit.
do you mean ouptu when the program in running Is it a windows application or console app You should be able to look at the Output window in visual studio to see any output you have wrtitten.
in this console application program an error is shown in visual C# 20005 n the error is 'System..IO.StreamReader' does not contain a definition for 'ReadLine' which is highlighted by blue color....... plz tell me the solution
using System; using System.Collections.Generic; using System.Text; using System.IO;
namespace program { class Program { public static void Main(string[] args) { try { int ctr=0; if (args.Length<=0) { Console.WriteLine("Format listIT filename"); return; } else { FileStream f= new FileStream(args[0],FileMode.Open); try { StreamReader t= new StreamReader(f); String line; while ((line = t.ReadLine() )!=null) { ctr++; Console.WriteLine("{0}: {1]",ctr,line); } f.Close(); } finally { f.Close(); } } } catch(System.IO.FileNotFoundException) { Console.WriteLine("ListIT Could not Find the File",args[0]); } catch(Exception e) { Console.WriteLine("Exception : {0} \n\n",e); }
how can we see output?
ogagnol
Irina777
Hi,
you can use System.Threading.Thread.Sleep(5000); which will pause the main thread for 5 seconds before allowing the console to exit. As mentioned you could also use Console.ReadLine() but that would then require you to press enter for the console application to exit.
Mark.
GarethJ - MSFT
papadi
Console.WriteLine("{0}: {1]",ctr,line);
to
Console.WriteLine("{0}: {1}",ctr,line);
Spangltk
Linda2270
Hi,
do you mean ouptu when the program in running Is it a windows application or console app You should be able to look at the Output window in visual studio to see any output you have wrtitten.
Mark.
iSerg
My dear friend
Instead F5 do Ctrl + f5. thats it.
Shyamal Patel
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace program
{
class Program
{
public static void Main(string[] args)
{
try
{
int ctr=0;
if (args.Length<=0)
{
Console.WriteLine("Format listIT filename");
return;
}
else
{
FileStream f= new FileStream(args[0],FileMode.Open);
try
{
StreamReader t= new StreamReader(f);
String line;
while ((line = t.ReadLine() )!=null)
{
ctr++;
Console.WriteLine("{0}: {1]",ctr,line);
}
f.Close();
}
finally
{
f.Close();
}
}
}
catch(System.IO.FileNotFoundException)
{
Console.WriteLine("ListIT Could not Find the File",args[0]);
}
catch(Exception e)
{
Console.WriteLine("Exception : {0} \n\n",e);
}
}
}
}