lucky3's Profile User Rating: *****

Reputation: 233 Stalwart
Active Posts:
774 (0.47 per day)
19-October 11
Profile Views:
Last Active:
User is offline Apr 16 2016 12:05 AM

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Favorite Gaming Platform:
Your Car:
Dream Kudos:
Expert In:

Latest Visitors

Icon   lucky3 Diving into BDD and TDD

Posts I've Made

  1. In Topic: Delegates/Events are just not sticking

    Posted 31 Dec 2014

    It's really easy (once you wrap your head around ;)): delegates are just signatures of methods, and declaring events is just telling what will the signature of event handling method look like.

    I hope you will understand that previous (simple) statement, with this examples:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    public static class MainClass
        public delegate void SomeVoidSignature(string message);
        delegate bool SomeBoolSignature(int first, int second);
        public static event SomeVoidSignature MyFirstDummyEvent;
        public static event Action<string> MySecondDummyEvent;
        public static void Main()
            Console.WriteLine("Void delegate examples:");
            #region void delegates
            var firstVoid = new SomeVoidSignature(FirstLog);
            firstVoid("Log this!");
            var secondVoid = new SomeVoidSignature(SecondLog);
            secondVoid("Log this!");
            var thirdVoid = new Action<string>(message => Console.WriteLine(@"This is message: ""{0}"" from third delegate method!", message));
            thirdVoid("Log this!");
            Action<string> fourthVoid = message => Console.WriteLine(@"This is message: ""{0}"" from fourth delegate method!", message);
            "Log this!".Log(fourthVoid);
            "Log this!".Log(message => Console.WriteLine(@"This is message: ""{0}"" from anonymous method!", message));
            "Log this!".Log(Console.WriteLine);
            "Log this!".Log(FirstLog);
            OtherVoidSignature()("Log this!");
            var otherSignature = OtherVoidSignature();
            otherSignature("Now log this!");
            #endregion void delegates
            Console.WriteLine("Bool delegate examples:");
            #region bool delegates
            var firstBool = new SomeBoolSignature(AreSameValue);
            String.Format("Are 1 and 1 equal? The answer is: {0}!", firstBool(1, 1)).Log(Console.WriteLine);
            var secondBool = new SomeBoolSignature(AreDifferentValue);
            String.Format("Are 1 and 1 different? The answer is: {0}!", secondBool(1, 1)).Log(fourthVoid);
            Func<int, int, bool> areDifferent = (first, second) => first != second;
            String.Format("Are 2 and 1 different? The answer is: {0}!", areDifferent(2, 1)).Log(thirdVoid);
            Func<int, IEnumerable<int>, bool> anyGreaterThan = (comparer, numbers) => numbers.Any(x => x > comparer);
            String.Format("Is any of these greater than 100: 12, 500, 2? The answer is: {0}!", anyGreaterThan(100, new[] { 12, 500, 2 })).Log(FirstLog);
            // Predicate<T> is the same as Func<T, bool>  
            Predicate<IEnumerable<int>> isThereTheSameElementInSequence = numbers =>
                var list = numbers.ToList();
                return list.Distinct().Count() < list.Count();
            String.Format("Are there same elements in sequence: 300, 2, 50, 1, 2, 500? The answer is: {0}!",
                isThereTheSameElementInSequence(new[] { 300, 2, 50, 1, 2, 500 })).Log(thirdVoid);
            #endregion bool delegates
            MyFirstDummyEvent.Invoke("This is message from first event!");
            MySecondDummyEvent.Invoke("This is message from second event!");
        private static Action<string> OtherVoidSignature()
            return message => Console.WriteLine(@"Message from delegate method: ""{0}""", message);
        private static void FirstLog(string message)
            Console.WriteLine(@"This is message: ""{0}"" from FirstLog!", message);
        private static void SecondLog(string message)
            Console.WriteLine(@"This is message: ""{0}"" from SecondLog!", message);
        private static bool AreSameValue(int first, int second)
            return first == second;
        private static bool AreDifferentValue(int first, int second)
            return first != second;
    public static class Logger
        public static void SetEventListeners()
            MainClass.MyFirstDummyEvent += Log;
            MainClass.MySecondDummyEvent += Log;
        private static async void Log(string message)
            await Task.Delay(500).ContinueWith(t => Log(message, Console.WriteLine));
        public static void Log(this string message, Action<string> logCallback)
  2. In Topic: WPF cascading DataContext, like with DataGrid

    Posted 15 Dec 2014

    tlhIn`toq is my English "that bad" :rolleyes: ?
    Let me quote myself from SOF, perhaps this is clearer:


    If I inherit my custom control from DataGrid and use its Columns, DataContext flows from ItemsSource to Bindings in columns just fine. I would like to do the same with my custom control, which doesn't inherit from DataGrid. What is the magic behind DataGrid.Columns getting the context from ItemsSource?
  3. In Topic: Template Functions & Template Masks

    Posted 13 Nov 2014

    Hey AdamSpeight2008, I've read your blog post here, and it's a pity there's close to none readers of it. You provided VB.NET and C# examples, but in reality there are only VB.NET examples and no one noticed. I've just created new Azure VM with VS2015 preview, and installed SDK and other recommended VSIX. I will go through diagnostic and code fix scenarios, and will try your example as well. I'll be back with some more questions for sure. Thanks again for being helpful.
  4. In Topic: Template Functions & Template Masks

    Posted 8 Nov 2014

    First of, thank you Adam for your contribution. I must admit, I have no idea what this is about. Is this something new for Roslyn, or where should I start looking for? Where do those template and CS.Expr come from? Can you provide some useful links perhaps? I went searching for "template function", "template mask", "CS class", "CS.Expr", and so on. I'm sure I'm not the only one puzzled here :)

My Information

Member Title:
Friend lucky3 As IHelpable
40 years old
October 18, 1975
Jesenice, Slovenia, EU
Full Name:
Janez Lukan
Years Programming:
Programming Languages:

Contact Information



  • (2 Pages)
  • +
  • 1
  • 2
  1. Photo

    modi123_1 Icon

    31 Dec 2012 - 10:11
    Thanks.. I swear I just can't edge out a first place on those folk with a cult following. Hahahaha.. well.. that or you know.. their tremendous help they do (more so than I).
  2. Photo

    raghav.naganathan Icon

    28 Dec 2012 - 04:16
    Most welcome Lucky3 :) was very well deserved indeed :)
  3. Photo

    lucky3 Icon

    28 Dec 2012 - 03:24
    200th up vote by raghav.naganathan!
    Thank you.
  4. Photo

    lucky3 Icon

    25 Dec 2012 - 06:54
    Thanks smohd. Yeah, time passes so quickly sometimes... ;)
  5. Photo

    smohd Icon

    25 Dec 2012 - 04:14
    Hey Congratulations, nice work in forum.
    I havent been around for a long time
  6. Photo

    Xupicor Icon

    04 Dec 2012 - 12:31
    Nah, I'm not aiming at another award this month. I'm not working in IT, so I don't have access to a computer till late evening. And since I'm getting back to work, at least for some time - I won't have a chance to post as often as I did last month.
  7. Photo

    Xupicor Icon

    03 Dec 2012 - 12:22
    Grats, yet another award-winning performance. ;)
  8. Photo

    lucky3 Icon

    26 Nov 2012 - 07:16
    Thanks raghav. I must be blind or something, but I didn't see your answer for 4 days.
  9. Photo

    raghav.naganathan Icon

    21 Nov 2012 - 22:46
    hehe...:)...yeah...I was always a fan of numbers from much that my email id consists of a perfect square ;)
    And yes..Congrats lucky3 on the expert badge. You truly deserve it :)
  10. Photo

    lucky3 Icon

    21 Nov 2012 - 14:51
    Haha... I've seen your (and raghav's) numbers game lately. Interesting, almost every number has some great story behind. Thanks for dropping by.
  11. Photo

    Xupicor Icon

    21 Nov 2012 - 13:58
    If only I had that kind of patience. ;) 555 posts, nice clean sphenic number. Oh, it's also Harshad/Niven number. And 147 rep - 147 AD is 900 years after founding of Rome, so it's nice too. ;) Gawd, Raghav, I cought it from you! :P
  12. Photo

    raghav.naganathan Icon

    20 Nov 2012 - 22:08
    Thank you very much lucky3 :) Well, I guess that is probably my nature :) When I see posts from beginners, I remember my beginner days and recollect the problems I used to face :) Sure, I shall continue to do so :) Thanks again :)
  13. Photo

    lucky3 Icon

    19 Nov 2012 - 09:49
    Thanks raghav. I see you all over the place ;) I don't think I've ever seen someone so kind as you are to newcomers and beginners. Always warm, kind, and positive words. Keep up doing it!
  14. Photo

    raghav.naganathan Icon

    19 Nov 2012 - 02:48 sure are a great asset in the VB forums :)
  15. Photo

    zethulon Icon

    14 Nov 2012 - 07:55
    Hey I need some help solving some errors on my project, could you help me?
  • (2 Pages)
  • +
  • 1
  • 2