Click here to Skip to main content
15,896,606 members
Home / Discussions / C#
   

C#

 
GeneralRe: I have a little problem with my application. Pin
Som Shekhar4-May-10 22:40
Som Shekhar4-May-10 22:40 
GeneralRe: I have a little problem with my application. Pin
Alex Manolescu5-May-10 9:14
Alex Manolescu5-May-10 9:14 
GeneralRe: I have a little problem with my application. Pin
Som Shekhar5-May-10 9:16
Som Shekhar5-May-10 9:16 
Questionread and write in file Pin
tek 20094-May-10 21:36
tek 20094-May-10 21:36 
AnswerRe: read and write in file Pin
Abhinav S4-May-10 22:19
Abhinav S4-May-10 22:19 
QuestionRe: read and write in file Pin
tek 20094-May-10 22:38
tek 20094-May-10 22:38 
AnswerRe: read and write in file Pin
Abhinav S4-May-10 23:29
Abhinav S4-May-10 23:29 
AnswerRe: read and write in file Pin
riced5-May-10 0:11
riced5-May-10 0:11 
membre123 wrote:
how to fill a standard list dictionary <> from a text file????


Here's a little sample - it has no error handling or anything nice about it.
using System;
using System.Collections.Generic;
using System.IO;

namespace ConsoleApplication1
{
   class Customer
   {
      public int ID;
      public string name;
   }

   class Program
   {
      static void Main(string[] args)
      {
         var Customers = new Dictionary<int, Customer>();
         using (StreamReader fs = new StreamReader(@"C:\Stuff\theInputFile.txt"))
         {
            string dataLine;
            while ((dataLine = fs.ReadLine()) != null)
            {
               string[] s = dataLine.Split(',');
               int id = int.Parse(s[0]);
               Customer c = new Customer();
               c.ID = id;
               c.name = s[1].Trim();
               Customers.Add(c.ID, c);
            }
         }

         foreach (var  item in Customers)
         {
            Console.WriteLine("ID: {0} Customer {1}", item.Key, item.Value.name );
         }
         Console.ReadLine();
      }
   }
}

What you have to do depends entirely on the declaration for Customer and the layout of the input file.
My input file looks like this:
1, Jet Black
2, Hugh Cornwell
3, Joe Strummer
4, Sid Vicious

membre123 wrote:
and what is the other command to read and write in a small file size to share filestream????


I don't know what this means.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.

GeneralRe: read and write in file Pin
tek 20095-May-10 3:49
tek 20095-May-10 3:49 
QuestionNeed help in regex replace method. Pin
Rohit16db4-May-10 21:15
Rohit16db4-May-10 21:15 
AnswerRe: Need help in regex replace method. Pin
OriginalGriff4-May-10 22:39
mveOriginalGriff4-May-10 22:39 
GeneralRe: Need help in regex replace method. Pin
Rohit16db5-May-10 1:40
Rohit16db5-May-10 1:40 
GeneralRe: Need help in regex replace method. Pin
OriginalGriff5-May-10 3:54
mveOriginalGriff5-May-10 3:54 
QuestionHow to retrive message list from p2p Pin
Saiyed Alam4-May-10 20:56
Saiyed Alam4-May-10 20:56 
QuestionListBox Controls Pin
Illegal Operation4-May-10 20:22
Illegal Operation4-May-10 20:22 
AnswerRe: ListBox Controls [modified] Pin
Dan Mos4-May-10 20:43
Dan Mos4-May-10 20:43 
AnswerRe: ListBox Controls Pin
Henry Minute5-May-10 2:56
Henry Minute5-May-10 2:56 
QuestionAdd column to excel Pin
yadlaprasad4-May-10 20:03
yadlaprasad4-May-10 20:03 
AnswerRe: Add column to excel Pin
Dan Mos4-May-10 20:16
Dan Mos4-May-10 20:16 
AnswerRe: Add column to excel Pin
yadlaprasad4-May-10 20:22
yadlaprasad4-May-10 20:22 
GeneralRe: Add column to excel Pin
Estys4-May-10 21:07
Estys4-May-10 21:07 
QuestionReg: Crystal Report Pin
Dotnetkanna4-May-10 19:21
Dotnetkanna4-May-10 19:21 
AnswerRe: Reg: Crystal Report Pin
Eddy Vluggen4-May-10 23:27
professionalEddy Vluggen4-May-10 23:27 
GeneralRe: Reg: Crystal Report Pin
Dotnetkanna5-May-10 0:17
Dotnetkanna5-May-10 0:17 
GeneralRe: Reg: Crystal Report Pin
Eddy Vluggen5-May-10 0:56
professionalEddy Vluggen5-May-10 0:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.