|
More like the garbage collector...
|
|
|
|
|
That's a real conundrum for the GC -
"OK, if this object is still around, at this point, I can't GC it until then. But... but what if I ... secretlly GC it before the if?"
|
|
|
|
|
Previous -> Read "CLR via C#" by Jeffrey Ritcher.
Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder.
Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.
|
|
|
|
|
Guess he don't believe the guys at microsoft!
|
|
|
|
|
Then, he must be a Genius
Previous -> Read "CLR via C#" by Jeffrey Ritcher.
Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder.
Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.
|
|
|
|
|
Hm. and why even initialize the variable if you're going to assign another value anyway?
|
|
|
|
|
Thanks.
Previous -> Read "CLR via C#" by Jeffrey Ritcher.
Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder.
Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.
|
|
|
|
|
And what is the " = new List<employee>()" doing there, either? Assign it one value, then if it isn't null, which it can't be, immediately assign it another value and discard the first object? Goofy.
|
|
|
|
|
Thanks for raising this point.
Previous -> Read "CLR via C#" by Jeffrey Ritcher.
Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder.
Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.
|
|
|
|
|
|
|
Do you two realize how much money you just cost CP with this waste of disk space? You better click on some ads to pay for your mistakes.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
What was that message??, now its not there
Previous -> Read "CLR via C#" by Jeffrey Ritcher.
Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder.
Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.
|
|
|
|
|
Weird, I wonder why they were removed. They just had a ton of smiley face icons.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
May be because of "Smiley Overflows"
Previous -> Read "CLR via C#" by Jeffrey Ritcher.
Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder.
Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.
|
|
|
|
|
You owe me for the bandwidth cost of 2396 unnecessary s! Only the icon has 831 bytes, which amounts to a total of 1,991,076 wasted bytes. Gotta count now the extra html chars and send you the invoice!
|
|
|
|
|
Well, the null has really nothing to do there. Check if(employees.Count()==0)
I would do like this
class TestClass()
{
List<Employee> employees { get; set; }
TestClass()
{
employees = GetEmployees();
}
private List<Employee> GetEmployees()
{
return (from oRec in DataModel.Employees select oRec).ToList();
}
}
The signature is in building process.. Please wait...
|
|
|
|
|
Thanks.
Previous -> Read "CLR via C#" by Jeffrey Ritcher.
Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder.
Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.
|
|
|
|
|
vonb wrote: return (from oRec in DataModel.Employees select oRec).ToList();
Why do so many people insist on adding a pointless "from x in source select x " query to their code, when it has the same result as the much more concise "source "?
private List<Employee> GetEmployees()
{
return DataModel.Employees.ToList();
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This was just a simple implementation of more complex queries which I actually use
publc List<Employee> GetEmployees(int departmentId)
{
return (from oRec in DataModel.Employees where oRec.DepartmentID == departmentId).ToList();
}
The signature is in building process.. Please wait...
|
|
|
|
|
That's one of the reasons why I tend to prefer the method-call syntax for most LINQ queries - if you remove the .Where(filter) clause, your code still looks sensible.
return DataModel.Employees.Where(oRec => oRec.DepartmentID == departmentId).ToList();
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Probably code that has been edited and then not refactored. No real wtf here, ey?
|
|
|
|
|
But that's not the case I have verified the previous versions from source control...
Previous -> Read "CLR via C#" by Jeffrey Ritcher.
Current -> Exploring WCF thru Apress' "Pro WCF" by Chris Peiris and Dennis Mulder.
Next -> Need to read "The Art of Computer Programming" by Donald E. Knuth.
|
|
|
|
|
lol. Then its probably just a brain fart, or late night coding session
|
|
|
|
|
Guess I don't know c# well enough, but I didn't this you could use any comparison operator against NULL. it's probably bad practice to even if the language allows it.
|
|
|
|