Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can this be interpreted as a bug?
Message
De
31/05/2006 05:12:33
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
31/05/2006 00:26:57
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01125597
Message ID:
01126088
Vues:
36
>>It's your code and would work this way 99.9%. It would be better IMHO if you compare type to type (w/o ToString() comparison). In C# it's as easy as:
>>
>>if ( loControl.GetType() == typeof(System.Web.UI.WebControls.Image) )
>>
>>However in VB I found it hard to find compatible code:
>>
>>if ( loControl.GetType().Equals( System.Type.GetType("System.Web.UI.WebControls.Image") ))
>>
Cetin
>
>I thought the addition of GetType() was the equivalent of what you mention. It does work well as is as I just tested it and it goes in for ImageMap when it is a type of ImageMap only and it goes in the other condition when it is a type of Image only.

Yes it would work but be defensive I mean.
With ToString() you're converting type info to a string and comparing to a constant. If you accidentally change a single letter's casing there then it'd fail (string comparison). Instead what I'm saying is to compare their Type (System.Type). In effect you're doing:
if "System.Web.UI.WebControls.Image" = "System.Web.UI.WebControls.Image"
which is true and we do it like that in VFP too. However in VFP it's the only way:( Any casing change on either side would cause it to break (or a little mistype might go unseen).
What I say instead do it like:
if Type = Type
' if Type.Equals( Type )
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform