Click here to Skip to main content
16,004,991 members
Home / Discussions / C#
   

C#

 
GeneralAdd an icon to dll in runtime Pin
Naveed72720-Jan-08 21:59
Naveed72720-Jan-08 21:59 
GeneralRe: Add an icon to dll in runtime Pin
Ed.Poore20-Jan-08 22:45
Ed.Poore20-Jan-08 22:45 
GeneralBest way to read the following XML Pin
N a v a n e e t h20-Jan-08 21:24
N a v a n e e t h20-Jan-08 21:24 
GeneralRe: Best way to read the following XML Pin
stancrm20-Jan-08 21:53
stancrm20-Jan-08 21:53 
GeneralRe: Best way to read the following XML Pin
N a v a n e e t h20-Jan-08 22:09
N a v a n e e t h20-Jan-08 22:09 
GeneralRe: Best way to read the following XML Pin
Guffa20-Jan-08 22:41
Guffa20-Jan-08 22:41 
GeneralRe: Best way to read the following XML Pin
N a v a n e e t h20-Jan-08 22:49
N a v a n e e t h20-Jan-08 22:49 
GeneralCasting and "as" operator Pin
DavidNohejl21-Jan-08 2:01
DavidNohejl21-Jan-08 2:01 
Ok, since you are asking for efficient code Smile | :)


N a v a n e e t h wrote:
if (iterator.Current is IHasXmlNode)
{
XmlNode xNode = ((IHasXmlNode)iterator.Current).GetNode();
objList.Add(xNode);
}


is operator looks up type of iterator.Current and checks if it is of type IHasXmlNode or derived, and returns true or false.
Cast does the same lookup and check, only it returns IHasXmlNode or throws invalid cast exception.

For this pattern there is as operator, which does the same check, and return IHasXmlNode if it succeeds or null if it fails. One null check is faster then type lookup & check. While it is possible that JIT recognizes this pattern and optimize your code anyway, I wouldn't bet on it Smile | :)



[My Blog]
"Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe


GeneralRe: Casting and "as" operator Pin
N a v a n e e t h21-Jan-08 2:32
N a v a n e e t h21-Jan-08 2:32 
GeneralConnect to db Pin
bingupta20-Jan-08 20:41
bingupta20-Jan-08 20:41 
GeneralRe: Connect to db Pin
StianSandberg20-Jan-08 21:19
StianSandberg20-Jan-08 21:19 
GeneralRe: Connect to db Pin
bingupta20-Jan-08 21:38
bingupta20-Jan-08 21:38 
Generalerror occoured while using XML Reader Pin
koolprasad200320-Jan-08 20:24
professionalkoolprasad200320-Jan-08 20:24 
QuestionRe: error occoured while using XML Reader Pin
CPallini20-Jan-08 22:34
mveCPallini20-Jan-08 22:34 
Generaljavascript code to retrieve value from a message box Pin
chithra.r20-Jan-08 20:04
chithra.r20-Jan-08 20:04 
GeneralProgressBar Pin
half-life20-Jan-08 20:03
half-life20-Jan-08 20:03 
GeneralRe: ProgressBar Pin
CPallini20-Jan-08 22:39
mveCPallini20-Jan-08 22:39 
GeneralRe: ProgressBar Pin
half-life20-Jan-08 22:43
half-life20-Jan-08 22:43 
JokeRe: ProgressBar Pin
CPallini20-Jan-08 22:49
mveCPallini20-Jan-08 22:49 
GeneralHelp with configuration file Pin
Ahmad Adnan20-Jan-08 19:57
Ahmad Adnan20-Jan-08 19:57 
GeneralRe: Help with configuration file Pin
Colin Angus Mackay20-Jan-08 22:55
Colin Angus Mackay20-Jan-08 22:55 
GeneralDate Time Format Pin
D i x y20-Jan-08 19:57
D i x y20-Jan-08 19:57 
GeneralRe: Date Time Format Pin
Naveed72720-Jan-08 20:07
Naveed72720-Jan-08 20:07 
GeneralRe: Date Time Format Pin
Vikram A Punathambekar21-Jan-08 1:35
Vikram A Punathambekar21-Jan-08 1:35 
GeneralRe: Date Time Format Pin
PIEBALDconsult21-Jan-08 3:25
mvePIEBALDconsult21-Jan-08 3:25 

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.