Click here to Skip to main content
15,920,633 members
Home / Discussions / C#
   

C#

 
GeneralRe: ListView state between row changing Pin
shadowWWL29-Jan-07 0:28
shadowWWL29-Jan-07 0:28 
GeneralRe: ListView state between row changing Pin
bobsugar22229-Jan-07 2:42
bobsugar22229-Jan-07 2:42 
QuestionSyntax Advice Pin
dabuskol28-Jan-07 23:56
dabuskol28-Jan-07 23:56 
AnswerRe: Syntax Advice Pin
bobsugar22229-Jan-07 0:04
bobsugar22229-Jan-07 0:04 
GeneralRe: Syntax Advice Pin
Christian Graus29-Jan-07 0:19
protectorChristian Graus29-Jan-07 0:19 
GeneralRe: Syntax Advice Pin
bobsugar22229-Jan-07 0:24
bobsugar22229-Jan-07 0:24 
AnswerRe: Syntax Advice Pin
andre_swnpl29-Jan-07 0:39
andre_swnpl29-Jan-07 0:39 
GeneralRe: Syntax Advice Pin
bobsugar22229-Jan-07 1:02
bobsugar22229-Jan-07 1:02 
My test says otherwise:

DataTable dt = new DataTable("table1");
DataColumn dc = new DataColumn("col1");
dt.Columns.Add(dc);

for (int i = 1; i < 1000000; i++)
{
    DataRow row = dt.NewRow();
    row["col1"] = "string" + i.ToString();
    dt.Rows.Add(row);
}

long start = DateTime.Now.Ticks;

for (int i = 0; i < dt.Rows.Count; i++)
{
    string s = (string)dt.Rows[i]["col1"];
}

long middle = DateTime.Now.Ticks;

foreach (DataRow r in dt.Rows)
{
    string s = (string)r["col1"];
}

long end = DateTime.Now.Ticks;

TimeSpan forLength = new TimeSpan(middle - start);
TimeSpan foreachLength = new TimeSpan(end - middle);

Console.WriteLine("for = " + forLength.ToString());
Console.WriteLine("foreach = " + foreachLength.ToString());<pre>

Output:
<code>for     = 00:00:00.9079668
foreach = 00:00:00.2661282</code> 

But in the scheme of things, less than a second to process 1000000 records, either way fine by me.

GeneralRe: Syntax Advice Pin
andre_swnpl29-Jan-07 1:07
andre_swnpl29-Jan-07 1:07 
GeneralRe: Syntax Advice Pin
Luc Pattyn29-Jan-07 1:08
sitebuilderLuc Pattyn29-Jan-07 1:08 
GeneralRe: Syntax Advice Pin
bobsugar22229-Jan-07 2:24
bobsugar22229-Jan-07 2:24 
GeneralRe: Syntax Advice Pin
Luc Pattyn29-Jan-07 2:47
sitebuilderLuc Pattyn29-Jan-07 2:47 
GeneralRe: Syntax Advice Pin
ShermansLagoon29-Jan-07 3:02
ShermansLagoon29-Jan-07 3:02 
GeneralRe: Syntax Advice Pin
Luc Pattyn29-Jan-07 3:29
sitebuilderLuc Pattyn29-Jan-07 3:29 
GeneralRe: Syntax Advice Pin
Martin#29-Jan-07 1:06
Martin#29-Jan-07 1:06 
Question"PRINTSCREEN" Pin
Amit Agarrwal28-Jan-07 23:56
Amit Agarrwal28-Jan-07 23:56 
QuestionSocket problem with Chat app Pin
GermanDM28-Jan-07 23:30
GermanDM28-Jan-07 23:30 
QuestionWeb Services Interopelability Issue Pin
blackjack215028-Jan-07 22:54
blackjack215028-Jan-07 22:54 
AnswerRe: Web Services Interopelability Issue Pin
blackjack215029-Jan-07 22:50
blackjack215029-Jan-07 22:50 
QuestionClosing form event Pin
george ivanov28-Jan-07 21:55
george ivanov28-Jan-07 21:55 
AnswerRe: Closing form event Pin
engsrini28-Jan-07 22:10
engsrini28-Jan-07 22:10 
AnswerRe: Closing form event Pin
Rahul.RK29-Jan-07 0:01
Rahul.RK29-Jan-07 0:01 
GeneralRe: Closing form event Pin
george ivanov29-Jan-07 3:58
george ivanov29-Jan-07 3:58 
QuestionMicrosoft.Office.Interop.Word Pin
zt.Prog28-Jan-07 21:03
zt.Prog28-Jan-07 21:03 
AnswerRe: Microsoft.Office.Interop.Word Pin
Michael Sterk28-Jan-07 21:17
Michael Sterk28-Jan-07 21:17 

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.