« first day (459 days earlier)      last day (4476 days later) » 

1:10 AM
99
A: Is there a reason for C#'s reuse of the variable in a foreach?

Eric Lippert The compiler declares the variable in a way that makes it highly prone to an error that is often difficult to find and debug, while producing no perceivable benefits. Your criticism is entirely justified. I discuss this problem in detail here: http://blogs.msdn.com/b/ericlippert/archive/20...

OMG, thank the Lord.
I'm about to cry.
 
 
9 hours later…
10:03 AM
Why do disabled form elements still submit to the server? I come from a PHP background where I am sure that disabled elements don't appear to be accessible server side.
 
@deed02392 First of all: This is a browser feature and has nothing to do with the server software.
Second of all: Why are you bothered by unwanted data? Just ignore it.
3
Q: What's the difference between disabled="disabled" and readonly="readonly" for textarea?

AndyI have read a bit on this, but I can't seem to find anything solid about how different browsers treat things. I'm building an app that has to be Section 508-compliant (screen-reader accessible) and work clear back to IE 6.

(Maybe it wasn't disabled, only set to readonly.)
 
10:19 AM
@christianstuder I checked the src, it's set to disabled="disabled". So is what you're saying that the browser actually submits ALL form elements? Thus making this language independant?
 
No, the browser is not supposed to send disabled form elements. That's what the standard says. I don't know if every browser follows it 100%.
But yes, this is language independant. The server only sees what the browser sends. And the server cannot know if the corresponding HTML element had a disabled-attribute set.
(HTTP is stateless.)
 
@christianstuder That's what I figured RE not supposed to send disabled form elements. Would be very strange if Firefox ignored this. Reviewing my code this is probably not the case. Thanks for the info!
 
You're welcome. (There are some nice tools to watch the communication between your client and the form: Firebug, Fiddler, Charles.)
 
Bonjour :)
 
@MrAnubis Allo
 
10:28 AM
@deed02392 you meant Hello?
 
@MrAnubis I thought we were playing 'Say hello in different languages'?
 
@deed02392 Do you reply a French guy in Chinese? :D
 
@MrAnubis Nihao Fayuguo ren :D
 
@deed02392 What's up?
@deed02392 0_o , you really know many spoken languages I think :)
 
@MrAnubis I am just at work doing some Visual Web thing to replace spreadsheets. You?
@MrAnubis Just English, German and Chinese! Languages interest me.
 
10:32 AM
@deed02392 I prefer english or HP spells :D
 
@MrAnubis Hahaha, nice. I am not sure how to say hello HP spell style, but I imagine it's a mix-match of Latin and the English for hello ;)
 
@deed02392 Hello in HP -> Avada Kedavra!!!
Damn , that way we both will end killing each other
 
@MrAnubis Not quite the polite greeting we are used to here :P
 
@deed02392 don't worry that spell doesn't works in real world :)
 
@christianstuder is there a way to make this work: pastebin.com/HTianJFt
 
10:39 AM
@yas4891 Why are you asking me that directly?
Hmm, I don't know. I assume your code doesn't work, otherwise you wouldn't ask.
 
@christianstuder weil du es einfach drauf hast :)
 
@yas4891 Suck up ;)
 
@yas4891 Can you decode that?
 
@yas4891 Eher nicht, ich hänge hier nur schon seit einem Jahr rum, um Wissen zu absorbieren. Und kämpfe daneben im Visual Studio mit der strengen Typisierung...
 
@christianstuder :-)
ah... I've found the solution. Google + SO FTW!
Skeet FTW ^^
 
10:41 AM
@yas4891 What was it?
 
Here we go ...... left ....right.....ouch..fell in lake 0_o
 
35
Q: A generic list of anonymous class

DHornpoutIn C# 3.0 you can create anonymous class with the following syntax var o = new { Id = 1, Name = "Foo" }; Is there a way to add these anonymous class to a generic list? Example: var o = new { Id = 1, Name = "Foo" }; var o1 = new { Id = 2, Name = "Bar" }; List<var> list = new List<v...

 
What about new List<object>()?
You can put ANYTHING in there...
 
@christianstuder yeah, but you loose the benefits of the strongly-typed system
I basically failed in my first google attempt, because I could not remember that those classes are called "anonymous"
 
@yas4891 You might notice now that I'm actually a web developer used to PHP and JavaScript. ;-)
 
10:45 AM
@christianstuder Weiche, TEUFEL!
 
@yas4891 Buahahah. :-)
Anyway, what do you do with anonymous objects then? You can only use them more or less localy, right? If you pass them around, how does the compiler know that you've got a certain field, i.e. object.Status exists?
 
@christianstuder because the resolution happens at compile time, so you could effectively pass that around
I use it locally. The underlying type (not the anonymous) is a cross-application context type using .NET Reflection. So calls there are expensive and by caching the values ONCE on this side of the boundary, I increase performance
and YES: I've profiled this and YES, this is a bottleneck :)
 
(I wasn't saying anything.)
;-)
But you cannot really design methods which accept anyonmous objects, right?
 
private static List<T> CreateList<T>(IEnumerable<T> enumerable)
{
return new List<T>(enumerable);
}
just did that
formatting here is a bitch
 
What about private static int GetValue(Object o) { return o.Value; }? There's more than one problem with that...
 
10:54 AM
but yeah. I can now pass my LINQ query from the pastebin above to that method
@christianstuder yes. because Object doesn't have Value
but this is valid => private static dynamic Get(dynamic obj) { return obj.Value; }
 
Yes, so you cannot do effectively anything with the fields of a random object passed to you.
Hmm, thanks, I guess I'll have to do some research into dynamic then.
 
exactly. But you can use the new dynamic keyword. But I somewhat distaste that
@christianstuder Often it is not necessary. As with the example above: The compiler can handle all this
and you get IntelliSense with the above approach
 
Can anyone link me to compilation model of C#?
 
@yas4891 Hehehe, the classic divide between strongly and weakly typed programmers. ;-)
 
11:11 AM
gtg
/leave
 
 
1 hour later…
12:34 PM
@yas4891 is that an IRC command you were trying to punch on SO chat?
 
 
2 hours later…
2:13 PM
WPF font aliasing makes me cry :(
 
 
1 hour later…
3:18 PM
/leave
 
3:47 PM
@MrAnubis yes.... sorry for that
Hi all @jaminator @CBarlow @kcbeard
 
i have my site setup using master pages for the themes how does one tell it to load a dfferent webuser control based on which site is selected
for example cookstown lpccarvans are two sites with setting in web.config
 
 
1 hour later…
4:59 PM
@yas4891 can you review my little code?
anyone alive?
 
5:54 PM
@MrAnubis uhhmm.... I need to take a closer look there ;-)
 
6:10 PM
Good evening|day|morning!
Don't you know where is this checkbox that enables breakpoint in VS2010 at application start? It's annoying to break each time on Main().
 
@MajesticRa I don't know this checkbox
just insert a breakpoint
 
The checkbox is set already . The brakepoint is already there. Always!
So I can't find how to disable it
It automatically breaks on application start at the beginning of Main()
 
@MajesticRa ah OK!
 
I even remember that this checkbox exists. But can't find it for 30 minutes already...
Ahh... Looks like have to add ∞+1 question to stackoverflow...
 
6:29 PM
WOOOOHUUUUUU!!!!!
English NATO SLP 4344 !
 
How would I perform white box testing on this method
private static void selectTop20Tags(Dictionary<string, int> list)
{
//Outputs the top 20 most common hashtags in descending order
foreach (KeyValuePair<string, int> pair in list.OrderByDescending(key => key.Value).Take(20))
{
Console.WriteLine("{0}, {1}", pair.Key, pair.Value);
}
}
please help
 
@ElliotBrown there are already very good answers to your question over on SO
 
usr
6:51 PM
@Elliot: Use Microsoft Pex
 
Links
?
@usr cool thanks
 
usr
7:13 PM
Pex rulez whitebox testing of algorithmic code
Far superior to manual test case writing
Finds bugs that make you laugh cause they require so complicated inputs
 
 
1 hour later…
sbi
8:17 PM
If I have a string like "New Item 2", what would be the best way to split it into its begin and the number at the end? That is, I want to end up with "New Item " and 2.
 
Is the "New Item " part fixed?
 
sbi
@RMartinhoFernandes Currently, it is (although it's not "item"), but I plan to reuse that algorithm for other types, so, no, it isn't.
 
Ah. Then maybe a regex.
 
sbi
@RMartinhoFernandes Ah, Ok, good idea. I just look for a space and a number.
 
You know your way around that?
new Regex(@" \d").Split(input, 1) should produce an array with the two parts.
Untested.
 
sbi
8:26 PM
@RMartinhoFernandes Thanks!
 
@sbi Wait! That will eat the number and the space!
I suppose you want to keep the number too.
 
sbi
@RMartinhoFernandes I don't mind the space, I will need the number, though. I'm currently reading into this.
If you have something quicker, feel free to shoot. It's 9:30pm here, and I want to go home.
 
Well, you could either use a smart (read: less readable) regex, or get the start index of the number from the length of the first part.
string number = input.Substring(parts[0].Length); plus or minus one.
@sbi That should work and be decently readable.
 
sbi
@RMartinho What using do I need to get Regex? I'm lost at MSDN trying to find that. :-{
 
System.Text.RegularExpressions.
 
sbi
8:33 PM
System.Text.RegularExpressions
@RMartinhoFernandes :-/
 
var match = Regex.Match(input, @"^(.+) (\d+)$");
string text = match.Groups[1].Value;
string number = match.Groups[2].Value;
This is an alternative, but requires regex reading abilities.
@sbi hey, please let me know when you're good, so I can go have dinner (no worries, though, there's no one waiting for me).
 
sbi
@RMartinhoFernandes That's pretty good! Thanks! However, I think I need @"^(.*) (\d+)$".
Um, but then I'd need to make the space optional, too. Urgh. What's the .NET regex syntax for grouping "(.+) " and making it optional?
 
@sbi ((.+) )?
But now your group indices are changed!
Now you want groups 2 and 3.
 
sbi
@RMartinhoFernandes Yeah, that is inconvenient. But I'll just try to parse the last item into an integer. If it works, it's an index.
 
You can also use named groups, but I can't remember the syntax.
 
usr
8:45 PM
it goes like this: (?<name>.*)
Why not use @"(\d+)$" and get the index from the match to split the string?
 
sbi
@usr Mhmm. Hadn't thought about that.
 
usr
You can even do this: str.Reverse().TakeWhile(c => char.IsDigit(c)).Count() to get the length of the digit
the digits
 
sbi
@usr Uh. Right. However, I think I would have to add a comment to that for those who will have to look into that code later, while I can just assume that anyone here should be able to read and understand the regex. Sheepish grin.
 
usr
;-)
Depends on how used you are to LINQ and sequence processing tricks
a useful skill
now that I think about it I'd just use the groups feature: @"^(?<part0>.*?)(?<part1>\d+)$"
.*? means match as few as possible
 
sbi
@usr Well, I did understand that code at a glance, although I'm about as far from a C# wizard as you can get. But I happen to like LINQ a lot, and others here aren't as fond of it.
 
usr
8:56 PM
yeah you are right
maybe you like my regex which uses groups
that is pretty readable I think
 
9:13 PM
@sbi: I guess you have enough solutions :) I'm leaving now. Good night.
 
sbi
@RMartinhoFernandes Oh, sorry, I forgot! Yes, thanks!
 

« first day (459 days earlier)      last day (4476 days later) »