IRC Networks
Irc Logs Stats
Start date: 2007-09-27 02:48:27
Last update: 2008-10-24 20:19:38
Channels: 41
Logged Lines: 6230436
Size: 1825.67 MB
Powered by
Channel Info
Network: freenodeChannel: #csharp |
Search in www.irclog.org
Log from #csharp at freenode 2006-07-29
[12:21]<mracn>like so: List<CheckBox> a = new List<CheckBox>(); a.Add(chkUTF1);
[12:22]<mracn>or in .net 1.0 or 1.1: ArrayList a = new ArrayList(); a.Add(chkUTF1);
[12:22]<mracn>the difference is when you want to get that item back later on
[12:22]<mracn>such as: a[0].Checked = true;
[12:22]<mracn>that works for List<>, but not ArrayList
[12:22]<mracn>with ArrayList, you have to do this: ((CheckBox)a[0]).Checked = true;
[12:23]<mracn>which is not only annoying, it's also potentially dangerous
[12:23]<mracn>if you're 100% sure that the item in the array list is a checkbox, it doesn't matter, but you'll get an InvalidCastException if it can't cast the object to a CheckBox
[12:24]<mracn>what you can do in that case is use the "as" operator and check for null: CheckBox box = a[0] as CheckBox; if (box != null) box.Checked = true;
[12:24]<cjmgrug>Macke: is (a[0] as Checkbox).Checked = true; safer/better in any way than ((CheckBox)a[0]).Checked = true; ?
[12:24]<mracn>but anyway, if you're in .net 2.0, you'd want to check out Generics
[12:25]<mracn>CodeRun: No, since you'll get a NullReferenceException if the first fails, and an InvalidCastException if the second fails.
[12:25]<cjmgrug>i see
[12:25]<mracn>however, if you check for null after using "as", you can avoid that
[12:25]<mracn>but really, if you're in .Net, there's no need to use ArrayList
[12:25]<cjmgrug>right.
[12:25]<mracn>err, .Net 2.0 that is
[12:27]<znzj>mac|gyver: what would you use instead?
[12:27]<znzj>Macke rather, gah.
[12:28]<znzj>I'm a Java guy, so my instinct would be to use ArrayList unless I know for some particular reason there a better/more suitable alternative. Of course in Java ArrayList isn't thread safe so...
[12:28]<mracn>List<>
[12:28]<znzj>List<> isn't an abstraction?
[12:28]<mracn>List<> and ArrayList are essentially similar
[12:29]<mracn>no, it's a generic implementation of ArrayList, afaik
[12:29]<zgzzcygnv>generics are always better
[12:29]<zgzzcygnv>always
[12:29]<znzj>doesn't that kinda make ArrayList redundant?
[12:29]<zgzzcygnv>yes
[12:29]<mracn>Zero: Indeed
[12:29]<zgzzcygnv>ArrayList exists only for backwards compatability
[12:29]<znzj>AnarkiNet: Except when you're comparing to List<object> :)
[12:29]<znzj>I see.
[12:30]<zgzzcygnv>Zero - i fail to see how that wouldnt be better
[12:30]<znzj>It's messy and yet no more helpful
[12:30]<zgzzcygnv>last i read, generics are faster than like things that just take an Object
[12:30]<zgzzcygnv>messy how?
[12:30]<zgzzcygnv>i also fail to see how generics are messy...
[12:31]<zgzzcygnv>theyre far cleaner than what they replace, imho
[12:31]<znzj>AnarkiNet: It's like comparing, say, Perl to Delphi ;p
[12:31]<znzj>in fact no, Delphi is a bad example because it has pointers and other symbols... VB or Ruby might be a better example :)
[12:31]<zgzzcygnv>i don't know either of those two, because i'm not a massochist
[12:31]<znzj>heh.
[12:32]<zgzzcygnv>i think you need to take Analogies 101
[12:32]<znzj>basically, Perl is bloody messy and often unreadable.
[12:32]<mracn>How do you know you have to be a masochist to know those languages, if you do not know the languages themselves?
[12:32]<znzj>Generics don't help readability in any way.
[12:32]<zgzzcygnv>ArrayList vs List<T> is comparing two language features, not two seperate languages
[12:33]<zgzzcygnv>Macke, i've seen source code (yes, non-obfuscated source code for perl is STILL hideous)
[12:33]<zgzzcygnv>its like PHP but, if possible, worse
[12:33]<znzj>AnarkiNet: I'm talking in general, with the kind of strings and code blocks you end up with. The readability is typically hideous.
[12:33]<zgzzcygnv>erm, no
[12:33]<zgzzcygnv>its much easier to read generics
[12:34]<znzj>PHP is a great language imo (in some ways - it's bad in the same ways as VB).
[12:34]<zgzzcygnv>perhaps you need to actually use them before your ass goes off at high speed spouting garbage?
[12:34]<znzj>not for all reasons it isn't.
[12:34]<znzj>AnarkiNet: I use them day-to-day in Java.
[12:34]<zgzzcygnv>generics? last i heard, java doesnt even have them
[12:34]<zgzzcygnv>it has templates or something
[12:34]<znzj>AnarkiNet: Consider in Java you have, say, ArrayList<Object>, or ArrayList. How is ArrayList<Object> 'neater' by any definition of the word? Even though it's functioanlly equivelant.
[12:35]<zgzzcygnv>i don't use java, because i prefer to *not* fill up my system ram all the time
[12:35]<znzj>no, C++ has templates, which are nothing like.
[12:35]<zgzzcygnv>what the fuck
[12:35]<zgzzcygnv>ArrayList is NOT a generic
[12:35]<zgzzcygnv>List<T> is a generic
[12:35]<znzj>I said 'Consider in Java'. Learn to read, please :)
[12:35]<zgzzcygnv>and if you are doing List<Object>, thats not the language's fault, thats *YOUR* fault
[12:35]<znzj>Sometimes you don't have a choice what objects you're storing.
[12:36]<zgzzcygnv>sometimes you design programs correctly
[12:36]<zgzzcygnv>well, maybe you don't
[12:36]<zgzzcygnv>but others do
[12:36]<zgzzcygnv>don't blame the language for your own failings
[12:36]<znzj>you seem to be of the illusion that you get to design the way every application you tie your applications to are written and designed by yourself.
[12:36]<zgzzcygnv>it's not an illusion
[12:36]<zgzzcygnv>i write self-contained apps, normally
[12:36]<zgzzcygnv>because of licensing issues
[12:37]<zgzzcygnv>however i code to conform with the reccomendations of microsoft
[12:37]<znzj>Like, for instance, JAXB which I use in most of my work (it's an XML->Java object binder). When you unmarshall xml documents, your nodes are essentially a subclass of Object. They can be a subclass of say, Node, but that's really not much help when Node can be one of any class.
[12:37]<znzj>Therefore if you're storing certain data, it might as well just be ArrayList<Object>, or, more simply, ArrayList
[12:37]<zgzzcygnv>This just in: We are in ##csharp
[12:38]<zgzzcygnv>Zero, bzzzt. wrong.
[12:38]<zgzzcygnv>first, you keep saying ArrayList<Object> which doesn't exist
[12:38]<znzj>what's your point? You're saying that no possibly application could possibly exist that behaves similarly for c#, or any other language? Wow... that's just.... wow.
[12:38]<znzj>AnarkiNet: OMFG.
[12:38]<mracn>Zero: AnarkiNet doesn't really know how to argue. He's like this all of the time...
[12:38]<mracn>Zero: Better just to ignore him.
[12:39]<zgzzcygnv>second, if your using Object as the type for a generic, you probably should be using just Object[]
[12:39]<znzj>Macke: I see :? He clearly doesn't know how to read, or store previously stated information/details in his head either :/
[12:39]<znzj>Macke: It's like that whole jokes about how you put the elephant in the freezer, then "how do you fit a giraffe in a freezer"
[12:39]<zgzzcygnv>ah
[12:39]<zgzzcygnv>austrialian and hmm
[12:39]<zgzzcygnv>.se is...
[12:39]<zgzzcygnv>well your both retards
[12:40]<jlvydus>...
[12:40]<zgzzcygnv>gnight...oh wait, no, dont have a good night
[12:40]<zgzzcygnv>die in a fire
[12:40]<zgzzcygnv>please.
[12:40]<mracn>Haha
[12:40]<znzj>It's you're. If you're going to insult someone, try not to look like a completely uneducated putz in the process.
[12:40]<vufvuzn>AnarkiNet: you're the one misusing the word "your" :)
[12:40]<vufvuzn>Zero: indeed







