Click here to Skip to main content
15,895,011 members
Home / Discussions / C#
   

C#

 
GeneralListView and Inserting Subitems Pin
valikac26-Apr-04 12:17
valikac26-Apr-04 12:17 
GeneralRe: ListView and Inserting Subitems Pin
Jon G26-Apr-04 12:59
Jon G26-Apr-04 12:59 
GeneralRe: ListView and Inserting Subitems Pin
valikac26-Apr-04 14:40
valikac26-Apr-04 14:40 
GeneralRe: ListView and Inserting Subitems Pin
osto26-Apr-04 17:17
osto26-Apr-04 17:17 
GeneralRe: ListView and Inserting Subitems Pin
valikac26-Apr-04 18:10
valikac26-Apr-04 18:10 
GeneralUsing Bitmap and got exception in dispose Pin
kobyb26-Apr-04 11:28
kobyb26-Apr-04 11:28 
Generalconditional operator (?:) performance Pin
Anonymous26-Apr-04 10:53
Anonymous26-Apr-04 10:53 
GeneralRe: conditional operator (?:) performance Pin
Daniel Turini26-Apr-04 11:21
Daniel Turini26-Apr-04 11:21 
Anonymous wrote:
In VB.NET, the IIF function is 300% slower than the if...else...end if clause (according to VB.NET in a Nutshell).
This information is wrong, or incomplete.
IIF is implemented as a function, and as such, evals both the true and the false part and returns only the true part.
It's easy to see if you run this code:

imports Microsoft.VisualBasic
imports System
imports System.Collections

public module MyModule
	function VerySlowFunc(ByVal i as integer) as integer
	   System.Threading.Thread.Sleep(10 * 1000)
	   Console.WriteLine("Veryslow called with parameter " + CStr(i))
	   return i * 2
	end function

	sub Main
		Console.WriteLine(IIF(true, VerySlowFunc(1), VerySlowFunc(2)))
        Console.ReadLine()
	end sub
end module


This takes 20 seconds to run and print 2 messages, because VB will evaluate both the true and the false part. Change it for an if and the code will take only 10 seconds to run and print only 1 message.

Answering the question: the :? operator on C# is as fast as an if, and does not have the VB.NET behavior.

Due to technical difficulties my previous signature, "I see dumb people" will be off until further notice. Too many people were thinking I was talking about them... Sigh | :sigh:
GeneralRe: conditional operator (?:) performance Pin
Mike Dimmick26-Apr-04 23:53
Mike Dimmick26-Apr-04 23:53 
GeneralRe: conditional operator (?:) performance Pin
Anonymous27-Apr-04 2:49
Anonymous27-Apr-04 2:49 
GeneralDataGrid row: RowState unchange problem Pin
Chris#26-Apr-04 10:47
Chris#26-Apr-04 10:47 
GeneralRe: DataGrid row: RowState unchange problem Pin
Heath Stewart26-Apr-04 11:50
protectorHeath Stewart26-Apr-04 11:50 
GeneralRe: DataGrid row: RowState unchange problem Pin
Chris#27-Apr-04 4:49
Chris#27-Apr-04 4:49 
GeneralGarbage collector Pin
Ruchi Gupta26-Apr-04 10:39
Ruchi Gupta26-Apr-04 10:39 
GeneralRe: Garbage collector Pin
SJ_Phoenix26-Apr-04 19:16
SJ_Phoenix26-Apr-04 19:16 
GeneralRe: Garbage collector Pin
Stefan Troschuetz26-Apr-04 20:40
Stefan Troschuetz26-Apr-04 20:40 
GeneralRe: Garbage collector Pin
Mike Dimmick27-Apr-04 0:04
Mike Dimmick27-Apr-04 0:04 
GeneralRe: Garbage collector Pin
Stefan Troschuetz27-Apr-04 0:28
Stefan Troschuetz27-Apr-04 0:28 
GeneralDockable main Program Pin
camasmartin26-Apr-04 10:35
camasmartin26-Apr-04 10:35 
GeneralRe: Dockable main Program Pin
surgeproof26-Apr-04 11:18
surgeproof26-Apr-04 11:18 
GeneralSystem.Web.Services.Protocols.SoapException Pin
Code Toad26-Apr-04 9:46
Code Toad26-Apr-04 9:46 
GeneralRe: System.Web.Services.Protocols.SoapException Pin
Heath Stewart26-Apr-04 10:11
protectorHeath Stewart26-Apr-04 10:11 
GeneralRe: System.Web.Services.Protocols.SoapException Pin
Code Toad27-Apr-04 3:58
Code Toad27-Apr-04 3:58 
GeneralCustomizing Controls in c# - Help Pin
stan2826-Apr-04 9:01
stan2826-Apr-04 9:01 
GeneralRe: Customizing Controls in c# - Help Pin
Heath Stewart26-Apr-04 9:28
protectorHeath Stewart26-Apr-04 9:28 

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.