Click here to Skip to main content
15,849,829 members
Home / Discussions / C#
   

C#

 
GeneralRe: I have a little problem with my application. Pin
Som Shekhar4-May-10 23:40
Som Shekhar4-May-10 23:40 
GeneralRe: I have a little problem with my application. Pin
Alex Manolescu5-May-10 10:14
Alex Manolescu5-May-10 10:14 
GeneralRe: I have a little problem with my application. Pin
Som Shekhar5-May-10 10:16
Som Shekhar5-May-10 10:16 
Questionread and write in file Pin
tek 20094-May-10 22:36
tek 20094-May-10 22:36 
AnswerRe: read and write in file Pin
Abhinav S4-May-10 23:19
Abhinav S4-May-10 23:19 
QuestionRe: read and write in file Pin
tek 20094-May-10 23:38
tek 20094-May-10 23:38 
AnswerRe: read and write in file Pin
Abhinav S5-May-10 0:29
Abhinav S5-May-10 0:29 
AnswerRe: read and write in file Pin
riced5-May-10 1:11
riced5-May-10 1: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 4:49
tek 20095-May-10 4:49 
QuestionNeed help in regex replace method. Pin
Rohit16db4-May-10 22:15
Rohit16db4-May-10 22:15 
AnswerRe: Need help in regex replace method. Pin
OriginalGriff4-May-10 23:39
mveOriginalGriff4-May-10 23:39 
GeneralRe: Need help in regex replace method. Pin
Rohit16db5-May-10 2:40
Rohit16db5-May-10 2:40 
GeneralRe: Need help in regex replace method. Pin
OriginalGriff5-May-10 4:54
mveOriginalGriff5-May-10 4:54 
QuestionHow to retrive message list from p2p Pin
Saiyed Alam4-May-10 21:56
Saiyed Alam4-May-10 21:56 
QuestionListBox Controls Pin
Illegal Operation4-May-10 21:22
Illegal Operation4-May-10 21:22 
AnswerRe: ListBox Controls [modified] Pin
Dan Mos4-May-10 21:43
Dan Mos4-May-10 21:43 
AnswerRe: ListBox Controls Pin
Henry Minute5-May-10 3:56
Henry Minute5-May-10 3:56 
QuestionAdd column to excel Pin
yadlaprasad4-May-10 21:03
yadlaprasad4-May-10 21:03 
AnswerRe: Add column to excel Pin
Dan Mos4-May-10 21:16
Dan Mos4-May-10 21:16 
AnswerRe: Add column to excel Pin
yadlaprasad4-May-10 21:22
yadlaprasad4-May-10 21:22 
GeneralRe: Add column to excel Pin
Estys4-May-10 22:07
Estys4-May-10 22:07 
QuestionReg: Crystal Report Pin
Dotnetkanna4-May-10 20:21
Dotnetkanna4-May-10 20:21 
AnswerRe: Reg: Crystal Report Pin
Eddy Vluggen5-May-10 0:27
professionalEddy Vluggen5-May-10 0:27 
GeneralRe: Reg: Crystal Report Pin
Dotnetkanna5-May-10 1:17
Dotnetkanna5-May-10 1:17 
GeneralRe: Reg: Crystal Report Pin
Eddy Vluggen5-May-10 1:56
professionalEddy Vluggen5-May-10 1: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.