private delegate int Operate(int x, int y);
Operate usedOperator;
int Add(int x, int y)
{
return x + y;
}
usedOperator.ToString() should return either "+" "-" or whatever method the delegate currently contains. Is this possible somehow?
EDIT:
Alternatives to the delegate approach would be fine too. I basically am writing a pro...
First, I was reading some forums and the help in MSDN and all says that a delegate can't be overloaded.
Now, I want to have something like this:
public delegate void OneDelegate();
public delegate void OneDelegate(params object[] a);
public void DoNothing(params object[] a) {}
public void DoSomething() { /* do something */ }
private ...
C# delegates have always been difficult for me to grasp and so I was very happy to stumble across logicchild's article on The Code Project web site titled "C# Delegates: Step by Step". He has a very succinct way of explaining C# delegates and I can recommend it to you. However, in trying out the examples, I see that are two ways to initi...
I am developing a C# .NET 2.0 application wherein at run-time one of two DLLs are loaded depending on the environment. Both DLLs contain the same functions, but they are not linked to the same address-offset. My question is regarding the function delegates in my application code.
public class MyClass
{
public delegate int MyFuncti...
Hi,
I found your code example below extremely helpful, however I don't understand the use
of expressions in the code... I am looking to modify this method to accept a delegate with a params object[] parameter.. any pointers would be greatly appreciated.
Simon Bridge ([email protected])
class EventProxy
{
static public Delegate C...
Hi again everyone, thanks for every help that you guys have given me so far !! :D
and now, i encounter some problem on me using jquery and ajax
i am fetching all of my user's photos from my database, calling them out into a grid and then applying a jquery pagination plug-in 'pajinate' using this code
$(function(){
$('#talent_pagin...
I have the below code that was working fine until I tried adding the bool NetworkAvailable = true portion. Now I get a Method name expected compile time exception at Line 4 below.
void NetworkStatus_AvailabilityChanged(object sender, NetworkStatusChangedArgs e)
{
var networkAvailable = e.IsAvailable;
SetUpdateHUDConnectedMode d =...
I'm reading the msdn library topic about genrics . There is an example of declaring event wiht generic delegates, but is it correct?
// Code block 8. Generic event handling
public delegate void GenericEventHandler<S,A>(S sender,A args);
public class MyPublisher
{
public event GenericEventHandler<MyPublisher,EventArgs> MyEvent;
pu...
Hello everybody,
I have a question what I try to understand for a wile.
When I am using API feed with jquery I always have a problem, it is "click", "ready" ... events, which makes me to apply some hacks or to choose another way.
For example Flickr API:
$.each(data.photoset.photo, function(i, rPhoto){
var basePhotoURL =...
Hi Experts,
I am stuck with this problem of mine and it will be great help if someone solves this
problem for me
What I am trying to do is :
1) Intialize a DataTable datatable in form load event and assign its defaultview to a
datagridview dgvresult
2) On click of a button start an STA thread (I am actually working with WatIN IE ...
I want to set the delegate of an object inside a class method in Objective-C. Pseudo-code:
+ (ClassWithDelegate*) myStaticMethod {
if (myObject == nil) {
myObject = [[ClassWithDelegate alloc] init];
// myObject.delegate = ?
}
return myObject;
}
In Java I would simply create an anonymous class that implement...
Possible Duplicate:
When would you use delegates in C#?
On what condition should we use delegates
...
Hey,
I have an issue by setting the delegate property for a ViewController which is presented modally. The code below is a modified copy of the example code for Presenting a View Controller Modally.
AddContactPersonTableViewController *addController = [[AddContactPersonTableViewController alloc] initWithNibName:@"AddContact...
Hi,
I am trying to access the UITextView delegates and have a problem
I have a UIViewController with the UITextViewDelegate protocol and a Nib containing the textView.
If I set the delegate inside viewDidLoad like "textView.delegate = self" and I touch the textView, the app crashes without logging errors.
If I start editing the textVi...
I just switched over from iPhone to Android and am looking for something similar to where in the iPhone SDK, when a class finishes a certain task, it calls delegate methods in objects set as it's delegates.
I don't need too many details. I went through the docs and didn't find anything (the closest I got was "broadcast intents" which se...
I have a method that expects an Action<string>
I call the method as follows:
commandProcessor.ProcessCommand(s=> ShowReceipt("MyStringValue"))
ProccessCommand(Action<string> action)
{
action.Invoke(...); // How do I get the reffered string?
}
Do I have to use Expression<Action<string>> ? If so, how do I get the parameter values?
...
How do i pass method to asynchronous delegate invocation, so that it could be explicitly processed asynchronously on second processor? Thanks in advance.
ADDED:
I had problem with encoding internet so sorry for upper case.
I have tried:
BTW Have no javascript enabled in browser so I can't add comments to this post. Will be editing this...
This code is returning me a list that I am trying to pass to another function.
_ucItem.lblItemName.Text = itemRow.Field<string>("ITEM_NAME").ToString();
_ucItem.pbxItemImg.Image = itemRow.Field<string>("IMAGE").ToString();
_ucItem.lblItemName.Text = itemRow.Field<string>("FK_ITEM_ID").ToString();
Here I want to replace this set of lin...
I wrote a code that looks somewhat like this:
Thread t = new Thread(() => createSomething(dt, start, finish) );
t.Start();
and it works (sometimes it almost feel like there are multiple threads)
yet I don't use any delegates.
What is the meaning of a tread without a delegate
If a delegate is necessary - then please tell me what and...
Hi
I have the following code which obviously has some duplication. I'm sure this could be removed using a delegate or Action but can't quite grasp it.
anyone got any ideas?
public void DealStartingCards()
{
for (int i = 0; i < 3; i++)
{
foreach (var player in Players)
{
...