Re: Some newbie questions

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx> wrote in message
news:u5YO%23SW2FHA.3492@xxxxxxxxxxxxxxxxxxxxxxx
> Bill,
>
> We are talking in my idea about columns. Rows as the OP ask, you can only
> get by index or by a find (where I see a rowfilter, a select or whatever
> than as the same). (or I miss something).
--Depends. You can get them using foreach syntax as well.
In this example though, the question was between referring to to value via
Table.Rows[WhateverIndex][ColumnIndexOrName] or looking for the ID value
which is just like any other value that was returned from the db. If
you're saying that referencing it via index is the fastest, then I agree
totally.

In a discussion about the typed
> and the untyped dataset. (As you know do I not see any difference than
> that a strongly typed dataset is inherited from the DataSet). with Jay B.
> I thought me to remember that he told me that he had read something in
> Davids book. I don't have Davids book.
-- Performance is notably different. While it's true that typed datasets
inherit from DataSet, DataSets inherit from Object if you go far enough up
the chain. I suspect it's for similar reasons that Strongly Typed
collections are quicker than non typed collections. When you iterate
through each element, there isn't the same amount of checking that needs to
be done internally [this is just a guess but I think it's a pretty safe
assumption). The performance differences between the two are notable in
absolute terms, but they both happen so fast that from a human's point of
view, the difference is negligible. I'm not sure I follow you though about
Jay, is he saying that he's seen better performance with typed or untyped
datasets.
>
> There are 6 overloaded methods to index an item in a datarow. In fact that
> are 3 because the rest is filtering the rowstatus.
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatarowclassitemtopic.asp
>
> To my suprise was the datacolumn indexer the fastest. Looking deeper in
> it, I thought me to remember, was it because the indexer gets the
> information from the datacolumn before he takes the item. The string was
> faremost the slowest, I thought because it was first searching the
> columname.
--I'd expect the string to be the slowest but the indexer part is what's
curious. In VB.nET for instance, the second one is faster which intuitively
is what you'd expect. But in C#, the first one is faster (yes, it's hard to
believe but if you check the IL, it is)

Dim TestTable As New DataTable("MyTable")

For i As Int32 = 0 To TestTable.Rows.Count
Debug.WriteLine(i.ToString())
Next
Dim x As Int32 = TestTable.Rows.Count
For z As Int32 = 0 To x
Debug.WriteLine(x.ToString) ' This is faster in VB.NET as you'd expect,
but in C# it's slower
Next

The same holds for columns so what's really 'faster' depends on many factors
and what's true in C# may not be the same for VB.NET and vice versa.
But in respect to the Columnindex, the index is faster b/c it doesn't have
to perform string lookups each time.
Next
>
> I hope this explains it more.
>
> Cor
>


.



Relevant Pages

  • Re: Newbie question: Can the class object member be specified as a variable?
    ... Public Default Property SomeField(FieldName as String) as Object ... Yet again, though, I'd recommend going through reflection ... > It is possible to create an indexer for your class. ... >> class object member to a corresponding DataReader member? ...
    (microsoft.public.dotnet.framework.aspnet)
  • setting property value erors in serviced components
    ... when I inherit the class from the ... ByVal sigortalituru As String, ByVal karneno As Integer, ByVal pgmid As ... ByVal unitekod As Integer, ByVal kaydet As Boolean) As ObjectImplements ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Implement a Case INsensitive string.Comtains method?
    ... The proper .NET way is to write a custom string class ... As far as inheriting goes, you shouldn't need to inherit any class. ... you can write an extension method for   ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: To All: String reverse problem
    ... On the Compact Framework, it takes a bit longer than using an indexer ... it takes a bit longer than the Append and a bit shorter ... static string ReverseIndex ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Indexed properties in .NET
    ... The following snippet shows how to implement an numeric index on a class: ... class ClassWithIndexer { ... > with only an integer as indexer. ... a string as indexer (as ...
    (microsoft.public.dotnet.general)