Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 08:53

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C#] delegate bool functions

Discussion on [C#] delegate bool functions within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2009
Posts: 127
Received Thanks: 27
[C#] delegate bool functions

Moin moin,
Nach langer zeit melde ich mich dann mal von den toten zurück
Ich habe ein kleines Problem, und zwar möchte ich eine bestimmte Funktion die Bsp. Einen zauber startet überladen.
Code:
Public static void Cast(string spellname)
{
        Casting(spellname)
}
Nun mochte ich aber durch die uberladung noch eine if frage einbauen. Ich habe schon gehört dass man sowas mit Lambda-Abfragen macht. Aber wie genau muss das aussehen? 1. Muss ja eine delegate erstellt werden
Code:
Public delegate bool booligate;
Aber wie geht es jetzt weiter kann mir da jemand ein Beispiel zeigen, und auch bitte ein Beispiel wie man die Funktion dann aufruft.

Lg
Theredvex
theredvex is offline  
Old 12/29/2012, 12:59   #2
 
elite*gold: 0
Join Date: May 2010
Posts: 793
Received Thanks: 268
Überladen heist eig nur, das du mehrere funktionen mit gleichem namen aber verschiedenen argumenten hast, also du kannst durch überladung keine if frage einbauen.

und wie du in einen lambda ausdruck aufrufst ist ganz einfach:
Code:
Func<int,int> quad = i => i*i;
int neun = quad(3);


Func<bool,string> kopfoderzahl= b => {if(b) return "kopf"; else return "zahl";};
string kopf = kopfoderzahl(true);
nkkk is offline  
Old 12/29/2012, 13:10   #3
 
elite*gold: 0
Join Date: Aug 2009
Posts: 127
Received Thanks: 27
Alles klar dann habe ich das mit dem überladen falsch verstanden. Ich möchte quasi ein paar IF Argumente mit in die Funktion geben so zum Beispiel
Code:
Public void beispiel( DIEFUNKTIONDIEICHSUCHE Check)
{
If(Spieler == ich && Check)
.....
Ich möchte also die Funktion mit den Parametern Spieler.IstAmLeben aufruffen, sodass Check bei der IF anfrage durch Spieler.IstAmLeben ersetzt wird
theredvex is offline  
Old 12/29/2012, 14:00   #4
 
elite*gold: 0
Join Date: May 2010
Posts: 793
Received Thanks: 268
Quote:
Originally Posted by theredvex View Post
Alles klar dann habe ich das mit dem überladen falsch verstanden. Ich möchte quasi ein paar IF Argumente mit in die Funktion geben so zum Beispiel
Code:
Public void beispiel( DIEFUNKTIONDIEICHSUCHE Check)
{
If(Spieler == ich && Check)
.....
Ich möchte also die Funktion mit den Parametern Spieler.IstAmLeben aufruffen, sodass Check bei der IF anfrage durch Spieler.IstAmLeben ersetzt wird
aso das ist auch einfach . ich nehme mal an das IstAmLeben ein funktion ohne argumente ist die ein bool zurückgibt:


Code:
class Spieler
{
..
beispiel(IstAmLeben);

oder

beispiel(()  => this.IstAmLeben());
..
}


Public void beispiel(Func<bool> Check)
{
If(Spieler == ich && Check())
.....
nkkk is offline  
Reply


Similar Threads Similar Threads
All Quest Functions Over 670 functions
06/08/2013 - Metin2 PServer Guides & Strategies - 21 Replies
Gretings this is very simple tut ther is all organized quest functions based on last pub rev 2089 If you know some quest functions is not ther let me know "if valid function of corse" addimage addmapsignal add_bgm_info
Eigenes Fenster außerhalb von BOOL InitInstance()
04/21/2012 - C/C++ - 4 Replies
Mein Problem liegt darin, dass ich 2 Fenster haben möchte, das eine sich jedoch nur öffnen soll wenn ich beispielsweise einen Button gedrückt habe. Also habe ich eine zweite Klasse gemacht etc. So, wenn ich nun das Fenster erstellen lasse, wo das erste auch erstellt wird( in BOOL InitInstance() ), funktioniert alles wunderbar d.h. sie öffnen sich beide gleichzeitig, aber das möchte ich ja nicht. Trage ich dann die Funktion CreateWindow() dahinein (außerhalb von BOOL InitInstance() ), dass...
New UDF - Old Functions :D
07/11/2009 - GW Exploits, Hacks, Bots, Tools & Macros - 14 Replies
xxx
GUI Functions
04/29/2009 - GW Exploits, Hacks, Bots, Tools & Macros - 2 Replies
In an effort to make the bots here less annoying to use, I've created this small proof-of-concept library. It uses the memory to read locations of GUI windows in guild wars, so no more having to specify coordinates. I've only added support for hard mode on/off and travel to/from guild hall, but you guys probably get the idea. Feel free to expand on this concept and add more functions. It would be nice if we could have a complete library for everything useful you can do with the GUI. A...



All times are GMT +1. The time now is 08:55.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.