[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Please support me on my quest to learn C# delegates today.
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 15
Thread images: 6
File: Delegates.png (550 KB, 601x531) Image search: [Google]
Delegates.png
550 KB, 601x531
Please support me on my quest to learn C# delegates today.
>>
File: help.png (57 KB, 978x669) Image search: [Google]
help.png
57 KB, 978x669
ill help
>>
File: 1e6ae2c2db84d6b6b9b5e040ca978b2.jpg (182 KB, 850x1511) Image search: [Google]
1e6ae2c2db84d6b6b9b5e040ca978b2.jpg
182 KB, 850x1511
>>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.
>>
File: 1441165540792.jpg (89 KB, 621x621) Image search: [Google]
1441165540792.jpg
89 KB, 621x621
>>51701338
>functions aren't treated as objects by default
>>
File: delegatesHowDoTheyWork1.png (41 KB, 1248x485) Image search: [Google]
delegatesHowDoTheyWork1.png
41 KB, 1248x485
>>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.
Thread replies: 15
Thread images: 6

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.