Please support me on my quest to learn C# delegates today.
ill help
>>51701032
what are you retarded??
delegates are simply function pointers,
fucking shake my head C# fags desu senpai desu-ne.
>>51701209
Oh, you don't ACTUALLY need to help. I am just going to force myself to post explanations so anon can understand because it helps me break it down for myself.
>>51701229
>delegates are simply function pointers,
Can you really tell me why you need them though? Also, OWIN/katana uses the shit out of them, which is why I need them in the first place.
Also, this is going to be retarded as fuck, but if you know javascript. In javascript I can just got:
<code>
var logOpIsAFag = function(){console.log('op a fag tho');};
</code>
Is a delegate basically doing the same in C#?
a delegate is a function which can be used as an object
>>51701311
>javascript
holy fucking shit anon, i feel so sorry for you, i didn't know you were this handicapped.
I guess i'll do my good deed for the day and help you out.
in C#, delegates are multicast and asynchronous, in other words, you can iterate over a set of delegates safely and they wont dead lock your shitty program.
obviously you can do this in C and C++ but you would have to implement the threading yourself.
>>51701338
>functions aren't treated as objects by default
>>51701338
What why. What does this even mean.
>>51701436
Can't I just iterate over some async functions? I am confused.
>>51701229
See, this is what baffles me. I just went through 3 minutes of bullshit to call the function through a different name.
//Helper.StringDelegate myDelegate = h.ReturnDescription;
Helper.StringDelegate myDelegate = new Helper.StringDelegate(h.ReturnDescription);
So, the commented out code is shorthand, in reality what we are doing is creating a new instance of the delegate object for some fucking reason and passing the function to it as an argument.
>>51702468
yes, its that way to conform to OOP.
it's like asking why we have classes and interfaces or functions ( or methods if youre a c# fag) with signatures like
void foo( T<E> param).
foo() is very reusable thanks to OOP.
it works the same way for delegates.
>>51703147
I appreciate you hanging around, Raichu. This is kind of a pain in the ass. I am trying to come up with situations where using these things is advantageous (I did find examples, but on my own), and I am hard-pressed to do so.
>>51703199
delegates are overkill for small projects.
besides adding more layers of abstraction doesn't result in a better program.
imo just know what delegates are used for and carry on.
>>51702195
>Console.ReadLine()
Stop this.
>>51703245
>implying implications
You have a better solution for keeping the console open while I am fucking around with testing than making it wait for an input?
>>51703238
I don't care about delegates as such, but I want to understand Lambda in detail. After that, I need to understand the WebAPI2 pipeline when used from OWIN/Katana, which uses delegates to run "intermediaries" (such as token auth) for your project. Posting all that just seemed really pretentious.