Kinetic Code Camp - Bring your skills, or lack thereof.. :dumpster_fire:

I’ve not played with the wiki functionality yet, so I will check it out.

Cool, it seems like I can set a single post (multiple?) in a thread as a wiki post.

That’ll work nicely.

horse GIF

Kevin, you were here for the Wiki conversation, no?

BTW, the old still points to this forum.

1 Like

Yeah but I’m running on a lack of coffee, and limited sleep.

I’m a bit off my game, and I haven’t used it before.

Also, in addition to my regular schedule, starting today, I have to move 7 people onsite to different offices, and 14 people onsite to an offsite location, and everyone has to be done and working like nothing ever happened by Monday.

Luckily I have help.

Ok I kept the top post for me and wikified the next two.

string.Equals(string1, string2)

I recently found that using the regular equality operator (==) with strings actually checks the values of the two strings, unlike straight C# code.

Is that always? or most of the time?
Is there a place for string.Equals to check for equality?

you can use it to ignore case

string.Equals(string1, string2, StringComparison.OrdinalIgnoreCase)

Just want to add a bit to the delegates, as I’ve played with them a LOT.

If you need to loop through a List<T> (or other types) and perform an Action on each, there’s a shorter syntax you can use. Example:

var NumberList = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

var EvenNumsOnly = new List<int>();

Action<int> AddEvenNums = i => 
    if ( i % 2 == 0 )
        EvenNumsOnly.Add( i );

NumberList.ForEach( AddEvenNums );

Another fun thing if you have a simple Func<T> or Action<T>, you can keep them in-line. From the example above, my delegate could be:

Action<int> AddEvenNums = i => if ( i % 2 == 0 ) EvenNumsOnly.Add(i);

or for a Func<T>:

// These two delegates do the same thing:

Func<string,string> ValidateString1 = input =>
    if ( string.IsNullOrEmpty(input) )
        return "Invalid Input";
    return "Input is Valid";

Func<string,string> ValidateString2 = input => string.IsNullOrEmpty(input)? "Invalid Input": "Input is Valid";

Added as a Tidbit

Added to the top as an expansion

I’m here for you, widgeters.

When I have time… so… good luck.

Great Idea Kevin !!

I think he was a member, but was still a lurker. :laughing: :rofl: :laughing:

And then I became a regurgitator.

You mean an ignitor, right?

That too.

Animated GIF

I’ll try to get y’all some new content next week. Got work / side work / and presentation slides to do. :sob:

Came across this the other day, you may enjoy,


Yes, this is much needed. I have tried many times to learn about lambda notation and I am immensely lost. From seeing it everywhere, I gather that it’s obviously very fundamental. (Though it hasn’t always existed?)

Like this little bugger. Why did it not work to simply say sum(x)? Why the need for lambda?

Quick answer: with the lambda expression you are telling it to iterate over the records in the dataset.table using the sum method on each TranQty item (field/column). Without the initial part how would it (compiler) know what items to sum? x is what rowset, dataset, table, column, list?


Insert → <Dear Uncle Kevin :rofl: >

dsReceipts.RcvDtl.Sum(x => x.ThisTranQty)

Well one area of confusion is there are 2 forms of lambda expression.

You have expressions, and statements.

What you have there, is an expression lambda.

The code above, in English says:

Please (be nice) return the sum of the field ThisTranQty from the RcvDtl table in the dsReceipts (TableSet or DataSet).

This part, is not lambda at all: dsReceipts.RcvDtl.Sum.
It is traditional Object Oriented Programming notation, so you have this:

decimal IamAvariableOffScreen = [Object][ChildObject][ExtensionMethodOnObjectByType]()

The next part is where the lambda is:

x => x.ThisTranQty

You can tell by the => operator.

This part defines that we’ll be working on x, and we will use the lambda operator => to define an “anonymous” “inline” “function” that returns the ThisTranQty field from x TO the Sum (Extension) Function.

The variable x will take on the value of what is fed in to it. In this case, it represents the RcvDtl table, as that is what we are running our extension method on.

We don’t see the magic Magic Fingers Family GIF of Sum here, but it takes a number of objects and does it’s thing. We are just using lambda to provide it the data.

I’ll explain further later, this is hard to get right and explain well.
This goes back to delegates, Actions, Funcs etc. I guess I will need to explain extension methods as well.

I will try to show how the cake :cake: is made eventually, but it’s a bit of a mouth full.

Chocolate Cake GIF

Fun fact, LINQ, is pretty much all extension methods, all the way down.