Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
V

Vincent Blais

@Vincent Blais
About
Posts
35
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Finally got that hardware upgrade!
    V Vincent Blais

    Dell regular price are always to high so they can have big sale as the 200 rebate currently in the US. I don't remember the last sale price I saw but is has probably close to AUD$450.00. Still higher than the US price even with taxes excluded but a good price for that monitor. I have the previous model (U2515D) at home and it great. Thinking about getting one for work as I miss having Visual Studio on a QHD resolution.

    Vince Remember the dead, fight for the living

    The Lounge csharp javascript linq com sysadmin

  • What book would you recommend to learn C# from 0?
    V Vincent Blais

    :thumbsup:++

    Vince Remember the dead, fight for the living

    The Lounge c++ learning csharp question

  • Hey Marc Clifton!
    V Vincent Blais

    Good call on returning an empty sequence. More in line with the standards in Linq for a collection. I have missed that one.

    Vince Remember the dead, fight for the living

    The Lounge

  • Hey Marc Clifton!
    V Vincent Blais

    Nice one The only thing I would change is to use an IEnumerable instead of a List. That would make the extension method more flexible and make FindExact defered execution instead of greedy because of the toList() Some quick write in LinqPad

    void Main()
    {
    List people = new List();
    people.Add(new Person { Name = "Joan", Age = 102 });
    people.Add(new Person { Name = "Pete", Age = 50 });
    people.Add(new Person { Name = "Walter", Age = 65 });
    people.Add(new Person { Name = "Joan", Age = 17 });
    people.Add(new Person { Name = "Walter", Age = 25 });

        var person1 = people.FindExact("Name", "Pete");
        var person2 = people.FindFirstExact("Name", "Walter");
        var person3 = people.FindLastExact("Name", "Joan");
    	
    	person1.Dump();
    	person2.Dump();
    	person3.Dump();
    

    }

    public class Person
    {
    public string Name { get; set; }
    public int Age { get; set; }

    public override string ToString()
    {
        return Name + " - " + Age.ToString();
    }
    

    }

    public static class Extensions
    {
    public static IEnumerable FindExact(this IEnumerable list, string valuePropertyName, string text)
    {
    IEnumerable found = default(IEnumerable);
    try
    {
    PropertyInfo info = typeof(T).GetProperty(valuePropertyName);
    found = from item in list
    let value = (string)(info.GetValue(item, null))
    where value == text
    select item;
    }
    catch (Exception)
    {
    }
    return found;
    }

    public static T FindFirstExact(this IEnumerable list, string valuePropertyName, string text)
    {
    	T found = default(T);
    	try
    	{
    		found = list.FindExact(valuePropertyName, text).FirstOrDefault();
    	}
    	catch (Exception)
    	{
    	}
    	return found;
    }
    
    public static T FindLastExact(this IEnumerable list, string valuePropertyName, string text)
    {
    	T found = default(T);
    	try
    	{
    		// Using Reverse here to not loop through the whole collection. 
    		// Could add a check if here if IList is implemented and only use LastOrDefault() in that case
    		found = list.Reverse().FindExact(valuePropertyName, text).First();
    	}
    	catch (Exception)
    	{
    	}
    	return found;
    }
    

    }

    Vince Remember the dead, fight for the living

    The Lounge

  • Headphones
    V Vincent Blais

    I have the PSB M4U 1 [^] and they are really comfortable. They also have a noise-cancelling version, the M4U 2[^]

    Vince Remember the dead, fight for the living

    The Lounge com tools question

  • Silly Batter Indicator
    V Vincent Blais

    Just saw it. Could it but a malfunction volume up button that is always pressed?

    Vince Remember the dead, fight for the living

    The Lounge mobile help question

  • Silly Batter Indicator
    V Vincent Blais

    This look exactly like the indicators (volume, brightness, etc.) on my Windows 8 Asus laptop. But it only show when I make change. Not idea why it is always showing or how to get rid of it.

    Vince Remember the dead, fight for the living

    The Lounge mobile help question

  • Lost my mum
    V Vincent Blais

    :rose:

    Vince Remember the dead, fight for the living

    The Lounge help announcement

  • Strange 512GB SSD cheaper than 480GB SSD??
    V Vincent Blais

    All the 512GB and 480GB SSD probably have the same 512GiB RAW capacity. It the effective over-provisioning and Sandforce RAISE (Redundant Array of Independent Silicon Elements) technology that change the number use in advertising http://www.tomshardware.com/reviews/ssd-520-sandforce-review-benchmark,3124.html[^]

    Vince Remember the dead, fight for the living

    The Lounge com question lounge

  • New Spammer?
    V Vincent Blais

    Done and gone

    Vince Remember the dead, fight for the living

    Spam and Abuse Watch com tools question

  • IEnumerable OrderBy on a text field
    V Vincent Blais

    __John_ wrote:

    It uses a 'lazy' strategy, ie. only evaluating an expression or executing a function when the result is actually needed, am I right?

    Yes you are right. It's a principle of Linq to defer execution until is needed. And Linq also evaluate only the elements needed to return the result Let's take Wayne List and do some examples

    List peoples = new List {new Person("wayne"), new Person("sarah"), new Person("mark"), new Person("simon"), new Person("ashleigh"), new Person("dave"), new Person("connor"), new Person("bronwyn"), new Person("chantelle"), new Person("will"), new Person("chris")};

    int Count = people.Count(p => p.Name.StartsWith("w")); //<-- Count is a greedy operator and all persons are evaluated for a result of 2.

    var firstperson = people.Where(p => p.Name.Length == 5).Take(3);
    foreach (var p in firstperson) // <-- evaluation start where and only Wayne, Sarah, Mark and Simon will be evaluated. The rest of the list is left alone
    {
    Console.WriteLine(p.Name);
    }

    // And to show you when Linq expression are evaluated, try
    var firstperson2 = people.Where(p => p.Name.Length == 5).Take(3);
    people.Insert(1, new Person("Vince"));

    foreach (var p in firstperson) // <-- evaluation start where and only Wayne, Vince ans Sarah, will be evaluated. The rest of the list is left alone
    {
    Console.WriteLine(p.Name);
    }

    http://blogs.msdn.com/b/charlie/archive/2007/12/09/deferred-execution.aspx[^]

    __John_ wrote:

    BTW: How can I enumerate the results more that once?

    If you use a Enumerator, you can use Reset to set the enumerator to its initial position, which is before the first element in the collection. But if you use a foreach loop, you can reuse an Enumerable many times. The foreach loop will start at the beginning every time.

    Vince Remember the dead, fight for the living

    C# sysadmin question

  • IEnumerable OrderBy on a text field
    V Vincent Blais

    The difference is not the IEnumerable or the List but where the OrderBy take place. When you call ToList,or any greedy query operators, you execute your Ling query against your DB. After that, all Linq operation are executed in memory and Linq-to-object can do more things in than Linq-to-sql, or Linq-to-entities

    Vince Remember the dead, fight for the living

    C# sysadmin question

  • Congrats To Chris Maunder
    V Vincent Blais

    wish I could give more than 5 for that! P.S. I need something to clean my monitor of coffee :rolleyes:

    Vince Remember the dead, fight for the living

    The Lounge

  • What song is playing in your head right now?
    V Vincent Blais

    Human 4 - Warcraft II music by Glenn Stafford

    Vince Remember the dead, fight for the living

    The Lounge question

  • Thanks to DavidAuld and others
    V Vincent Blais

    My pleasure

    Vince Remember the dead, fight for the living

    The Lounge c++ architecture

  • Friday Timewaster
    V Vincent Blais

    Nice try, but I beat you by 30 years for the US cent. :-\

    Vince Remember the dead, fight for the living

    The Lounge com

  • Friday Timewaster
    V Vincent Blais

    1956 and 1967 cent, here in Montreal and the 1956 is U.S!! :wtf:

    Vince Remember the dead, fight for the living

    The Lounge com

  • Friday Pink List - some more
    V Vincent Blais

    All gone

    Vince Remember the dead, fight for the living

    Site Bugs / Suggestions com

  • hardware question ... graphic card (continued from lounge post)
    V Vincent Blais

    You could also check the BIOS version. Version 1.A have "Improved VGA card compatibility" and I did run into problems a few year back when I upgraded a videocard to a Radeon 4580 on an Intel motherboard with a Q35 chipset. I could see the motherboard splash screen but it will freeze sortly after http://www.msi.com/product/mb/P67A-G43--B3-.html#?div=BIOS[^] Also check your pci-e connector as Peter said. Each GPU should have a 6 pins connector at the back. They are necessary for the card to work properly. And these connnector should come from the PSU, not the twin molex to pci-e connector bundled with the card. These adaptors are for those who don't have enough pci-e connector on their PSU (read older). Best of luck.

    Vince Remember the dead, fight for the living

    Hardware & Devices question com hardware performance

  • Spammers
    V Vincent Blais

    All of them should be history now. Dealt the 7 or 8 blows on a couple

    Vince Remember the dead, fight for the living

    Site Bugs / Suggestions com tools question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups