Click here to Skip to main content
15,892,537 members
Home / Discussions / C#
   

C#

 
GeneralRe: #if indentation Pin
Not Active29-Jan-10 13:05
mentorNot Active29-Jan-10 13:05 
JokeRe: #if indentation Pin
F2dk29-Jan-10 20:46
F2dk29-Jan-10 20:46 
GeneralRe: #if indentation Pin
#realJSOP30-Jan-10 8:25
mve#realJSOP30-Jan-10 8:25 
GeneralRe: #if indentation Pin
#realJSOP30-Jan-10 8:11
mve#realJSOP30-Jan-10 8:11 
GeneralRe: #if indentation Pin
Not Active30-Jan-10 13:19
mentorNot Active30-Jan-10 13:19 
GeneralRe: #if indentation [modified] Pin
#realJSOP30-Jan-10 8:33
mve#realJSOP30-Jan-10 8:33 
GeneralRe: #if indentation Pin
Not Active30-Jan-10 13:18
mentorNot Active30-Jan-10 13:18 
Questionbuilding a safe environemnt to run suspicious EXEs Pin
Mohamed hossam29-Jan-10 7:02
Mohamed hossam29-Jan-10 7:02 
AnswerRe: building a safe environemnt to run suspicious EXEs Pin
EliottA29-Jan-10 7:48
EliottA29-Jan-10 7:48 
GeneralRe: building a safe environemnt to run suspicious EXEs [modified] Pin
Mohamed hossam29-Jan-10 9:16
Mohamed hossam29-Jan-10 9:16 
AnswerRe: building a safe environemnt to run suspicious EXEs Pin
Ravi Bhavnani29-Jan-10 8:46
professionalRavi Bhavnani29-Jan-10 8:46 
GeneralRe: building a safe environemnt to run suspicious EXEs Pin
Mohamed hossam29-Jan-10 9:41
Mohamed hossam29-Jan-10 9:41 
QuestionDeserializing Generic List<object> taking a lot of time</object> Pin
abhinish29-Jan-10 4:34
abhinish29-Jan-10 4:34 
AnswerRe: Deserializing Generic List taking a lot of time Pin
Not Active29-Jan-10 6:19
mentorNot Active29-Jan-10 6:19 
GeneralRe: Deserializing Generic List taking a lot of time Pin
J4amieC29-Jan-10 6:34
J4amieC29-Jan-10 6:34 
AnswerRe: Deserializing Generic List taking a lot of time Pin
Ilia Blank29-Jan-10 6:52
Ilia Blank29-Jan-10 6:52 
GeneralRe: Deserializing Generic List taking a lot of time Pin
abhinish29-Jan-10 16:49
abhinish29-Jan-10 16:49 
GeneralRe: Deserializing Generic List taking a lot of time [modified] Pin
Ilia Blank1-Feb-10 4:54
Ilia Blank1-Feb-10 4:54 
Well, what I basically recommend using StreamWriter, StreamReader class to write to file /read from the file data stored in your objects. The approach requires specifying format of the file and how pieces of the data stored / retrieved from the file.  
When applied to your example is might look something like this

<code>
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Diagnostics;

namespace ConsoleApplication1
{
      public class CTempClass
      {
            public int m_uCrc64;

            public int M_uCrc64
            {
                  get
                  {
                        return m_uCrc64;
                  }

                  set
                  {
                        m_uCrc64 = value;
                  }
            }

            public CTempClass()
            {
                  m_uCrc64 = 0;
            }

      }


      class Program
      {
            static void Main(string[] args)
            {

                  List&lt;CTempClass&gt; lsTemp = new List&lt;CTempClass&gt;();

                  for (int i = 0; i &lt; 1000000; i++)
                  {
                        CTempClass oTemp = new CTempClass();
                        oTemp.m_uCrc64 = i;
                        lsTemp.Add(oTemp);
                        oTemp = null;
                  }
                  Stopwatch s = new Stopwatch();

                  s.Start ();

                  using (Stream stream = File.Open("c:\\data.bin", FileMode.Create))
                  {
                        BinaryWriter writer = new BinaryWriter(stream);

                        foreach (CTempClass instance in lsTemp)
                              writer.Write(instance.M_uCrc64);

                        writer.Close();
                  }

                  s.Stop();
                  System.Console.WriteLine ("Serialize " + s.Elapsed.TotalMilliseconds + " mils");

                  s.Reset();
                  s.Start();

                  byte[] buffer = File.ReadAllBytes ("c:\\data.bin");

                  lsTemp = new List&lt;CTempClass&gt;();

                  using (MemoryStream stream = new MemoryStream(buffer))
                  {
                        BinaryReader reader = new BinaryReader(stream);

                        try
                        {
                              while (true)
                              {
                                    int i = reader.ReadInt32();
                                    CTempClass oTemp = new CTempClass();
                                    oTemp.m_uCrc64 = i;
                                    lsTemp.Add(oTemp);
                                    oTemp = null;
                              }
                        }
                        catch (EndOfStreamException)
                        {
                              reader.Close();
                        }

                  }

                  s.Stop();
                  System.Console.WriteLine("Deserialize " + s.Elapsed.TotalMilliseconds + " mils");

            }
      }
}

</code>

modified on Monday, February 1, 2010 11:23 AM

Questionhow to reduce space in between two lines in word Pin
ravindra chintha29-Jan-10 1:35
ravindra chintha29-Jan-10 1:35 
AnswerRe: how to reduce space in between two lines in word Pin
Eddy Vluggen29-Jan-10 1:53
professionalEddy Vluggen29-Jan-10 1:53 
GeneralRe: how to reduce space in between two lines in word Pin
ravindra chintha29-Jan-10 1:57
ravindra chintha29-Jan-10 1:57 
GeneralRe: how to reduce space in between two lines in word Pin
ravindra chintha29-Jan-10 2:04
ravindra chintha29-Jan-10 2:04 
GeneralRe: how to reduce space in between two lines in word [modified] Pin
Eddy Vluggen29-Jan-10 2:20
professionalEddy Vluggen29-Jan-10 2:20 
QuestionSpeech Recognition Pin
krinaljariwala29-Jan-10 1:28
krinaljariwala29-Jan-10 1:28 
AnswerRe: Speech Recognition Pin
Migounette29-Jan-10 8:30
Migounette29-Jan-10 8:30 

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.