using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication14
{
class Program
{
static void Main(string[] args)
{
Console.Write("filename = ");
string filename = Console.ReadLine();
if (File.Exists(filename))
{
FileStream fp = new FileStream(filename, FileMode.Open);
StreamReader reader = new StreamReader(fp);
string data;
int e = 0;
while ((data = reader.ReadLine()) != null)
{
string[] or = data.Split(',');
e = e + int.Parse(or[1]);
}
reader.Close();
fp.Close();
Console.WriteLine(e);
}
else
Console.WriteLine("file is not found!");
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication14
{
class Program
{
static void Main(string[] args)
{
Console.Write("filename = ");
string filename = Console.ReadLine();
if (File.Exists(filename))
{
FileStream fp = new FileStream(filename, FileMode.Open);
StreamReader reader = new StreamReader(fp);
string data;
int e = 0;
while ((data = reader.ReadLine()) != null)
{
string[] or = data.Split(',');
e = e + int.Parse(or[1]);
}
reader.Close();
fp.Close();
Console.WriteLine(e);
}
else
Console.WriteLine("file is not found!");
}
}
}
No comments:
Post a Comment