I have been using LINQ with compiled queries, basically passing into the compiled query using Func but the problem is that it has a maximum of four parameters.
Is it good practice to extend this?
Is there any way to extend this or should I create my own delegate?
Sometimes I need to pass six params and others five and others four or l...
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually a derived class) and a Graph Viewer (based on Microsoft Research's Automatic Graphing Layout). Each has a context menu which can have similar events activated. While the list view can have multiple selections, I don't allow it on th...
When an array is given:
int[] a={1,3,4,5,67,8,899,56,12,33}
and if i wish to return the even numbers
using LINQ
var q=a.where(p=>p%2==0)
if i were to use C#2.0 and strictly func<> delegate what is the way to solve it?
I tried :
Func<int, bool> func = delegate(int val) { return val % 2 == 0; };
but confused how to link the arr...
I see lambda expressions have become a very useful tool at some points in the language. I've been using them a lot and most of the time they fit really nice and make the code shorter and perhaps clearer.
Now.. I've seen some , I would say excessive use of them. Some people like them so much that try to use them everywhere they can.. Som...
Why does the delegate need to call the EndInvoke before the method fires? If i need to call the EndInvoke (which blocks the thread) then its not really an asynchronous call is it?
Here is the code im trying to run.
class Program
{
private delegate void GenerateXmlDelegate();
static void Main(string[] args)
...
After each scroll (however large or small) of a UITableView, I would like to call -indexPathsForVisibleRows to run a method on the data that corresponds to visible cells.
Are there any existing notifications or delegate methods I can tap into when a UITableView is scrolled? I'd like to avoid subclassing.
EDIT
I ended up subscribing t...
I am developing a game that uses a different controller for each level. It needs to detect a shake via the accelerometer, so it registers itself as a delegate like so:
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
accel.updateInterval = kUpdateInterval;
When the level ends, this controller get...
I had trouble coming up with a good way to word this question, so let me try to explain by example:
Suppose I have some interface. For simplicity's sake, I'll say the interface is IRunnable, and it provides a single method, Run. (This is not real; it's only an example.)
Now, suppose I have some pre-existing class, let's call it Cheetah...
Hi,
Is it possible to use delegate in your Active Record model and use conditions like :if on it?
class User < ActiveRecord::Base
delegate :company, :to => :master, :if => :has_master?
belongs_to :master, :class_name => "User"
def has_master?
master.present?
end
end
Thnx!
...
Hello guys.
I`m having some trouble to understand why does a delegate works. I have many code examples, but i still could not grasp it properly.
Can someone explain it to me in "plain english"? Of course, examples of code will help, but i think i need more of a description of how/why it works.
EDIT:
Well, the question is: why does de...
If i declare a delegate
public delegate void firstDelegate(string str);
firstDelegate handler = Strfunc;
handler("Hello World");
..
static void Strfunc(string str)
{
Console.WriteLine(str);
}
will the compiler translate the following line
firstDelegate handler=Strfunc;
into
firstDelegate=new firstDelegate(Strfun...
As we know , When we load frame from webpage of safari, we will invoke the delegate methods of webkit informal protocol(WebFrameLoadDelegate):
webView:didStartProvisionalLoadForFrame:
webView:didChangeLocationWithinPageForFrame:
and When we click or change the tabs of safari,which delegate methods will be invoked? Thank you very much!...
Hi,
self.delegate = self; what's wrong in doing that?
and what is the correct way of doing it?
Thanks, Nir.
Code:
(UITextField*)initWith:(id)sender:(float)X:(float)Y:(float)width:(float)hieght:(int)textFieldTag {
if (self = [super initWithFrame:CGRectMake(X, Y,width, hieght)]) {
finalText = [[NSMutableString alloc] initWith...
Like Anonymous Methods ,the delegates i am declaring down using "delegate" keyword are anonymous delegates?
namespace Test
{
public delegate void MyDelegate();
class Program
{
static void Main(string[] args)
{
DelegateTest tst = new DelegateTest();
tst.Chaining();
Console.R...
Since Func<> delegates does not take "void" how could i acieve the following in C# 3.0
Func<int, int, void> delg = (a, b) => { Console.WriteLine( a + b); };
...
Hi all,
I've come to the point of pulling my hair out over this one. I keep getting a EXC_BAD_ACCESS when I call the reloadData for the UITableView. I'll lay the groundwork for you here.
MainViewController.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@class iPROSAppDelegate;
@interface MainViewController : UIViewCon...
Suppose I have code segment
namespace Test
{
public delegate void StaticticsDelegate(object sender,EventArgs e);
class DynamicDelegates
{
static void Main()
{
StaticticsDelegate del = BowlerStatistics;
BallThrownEventArgs be = new BallThrownEventArgs(90, 145);
del(Dynami...
I hava a delegate
public delegate void Context();
And i had implemented it by anonymous method,
public Context fakeHttpContext = () =>
{
...
create fake http context.
};
I dont' want to execute the fakeHttpContext by
fakeHttpContext.Invoke()
I wonder if i could invoke it by ...
I wrote a C# application that uses an unmanaged c++ dll via managed c++ dll.
In the unmanaged dll, there's a callback that one of its params is std::string &.
I can't seem to find the right way to wrap this with the managed dll.
When I use String ^, the callback works, but the C# application does not get anything in the string.
When I u...
Hi all i am trying to write and anonymous delegate. as the integer variable is shared among the delegate i need it to be the local instance of every delegate such that rs[0] always gets nics[0], rs[1] always gets nics[1] and so on... how will i achieve this.
for (int i = 0; i < nics.Count; i++)
{
rs[i] = new RollingSeries(mo...