Hi -
I recently asked a question about translating a code sample I found on on the internet from C# into VB and I was given links to websites that automate code translation (http://converter.telerik.com/ & http://www.developerfusion.com/tools/convert/csharp-to-vb/). I am very new to VB and unfortunately the VB that the translators retur...
I have a library project that uses ASIHTTPRequest to make URL requests and parse the responses. The library will be used by a separate iPhone app project.
If my iPhone controller code responds to a touch event, then calls into the library to make URL requests, how do I best perform the requests asynchronously?
In the library, if I use ...
When calling a delegate you always have to check if it is not null. This is an often cause for errors.
Since delegates are more or less just a list of functions, I would assume, that this could have been easily checked by the delegate itself.
Does anybody know, why it has been implemented as it is?
...
I'm able to compile code that includes this:
OperationDelegate myOpDelegate;
static OperatorDefinition[] definitions ={
new OperatorDefinition("+",2,3,true, new OperationDelegate(OperationAdd)),
};
delegate double OperationDelegate(double[] args);
static double OperationAdd(double[] args)
{
...
I have a method with two overloads, as follows:
bool Evaluate(Func<bool> condition)
{
// Some logic
return condition.Invoke();
}
bool Evaluate<T>(Func<T, bool> condition, T value)
{
// Same logic as the first method overload
return condition.Invoke(value);
}
Since both method overloads contain largely identical logi...
I have a ASP.NET web form that implements a wizard using a simple state machine, defined in another class and stored in a session variable. The functions to be executed when different states are reached are defined in the web form class, which passes a delegate array to the state machine during initialization. When the state machine ar...
Why, when an image does not exist at a specified URL, does didFailWithError not get called? For example:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/images/someImageIknowDoesntExist.jpg"]
cachePolicy:NSURLRequestReturnCacheDataElseLoad
...
I have two similar functions I hope to refactor to remove duplication:
IEnumerable<TotalType> GetTotalForMonths(string id, DateTime lastTotalDate)
{
for (int i = 0; lastTotalDate.AddMonths(i + 1) <= DateTime.Now; i++)
{
var totalStartDate = new DateTime(lastTotalDate.AddMonths(i).Year, lastTotalDate.AddMonths(i).Month, 1...
Hi,
I created a class where the main task is get data from the DB and mapping it to some object. The problem is the same class needs to map different datareader to different object. So, what I tried to do is to get out the mapping method using delegates.
Here is part of my code. See the important rows in bold.
public class GetDetails<...
Hi
Below function working ok but I want to make it simple.
if (list.Exists(delegate(string s) { return s.Contains(str); }))
{
string name = list.Find(delegate(string s) { return s.Contains(str); });
}
I am using delegate(string s) { return s.Contains(str); }
two times Is there any way to make this simple.
I know how to create ...
How to raise a event in usercontrol from the another usercontrol. i tried to do with delegates, but it doesnt work. How can i do this. am using C#(WPF)
usercontrol1.cs
public partial class UserControl1 : UserControl
{
delegate void myDelegate();
public UserControl1()
{
InitializeComponent();
}
private...
Is it good practice to invoke delegate for MainForm thread - this way?:
Txt.MainForm.EndInvoke(
Txt.MainForm.BeginInvoke(
new MethodInvoker(delegate()
{ // code here }
)));
...
Good Morning Users,
i have implemented the follwing deleagate Method:
- (void)openFlowView:(AFOpenFlowView *)openFlowView doubleTapOnIndex:(int)index itemView:(AFItemView *)itemView{
NSLog(@"Der Touch geht!!!!!");
}
And there the method should be prompted and called:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)eve...
Hi all,
Could someone please help me to understand how to get all parameters passed to delegate inside delegate itself?
I have class :
public class ShopManager : ShopEntities
{
public ShopManager getWhere(Func<Object, Object> dataList)
{
var x = dataList.???; // how to get arguments?
return this;
}
pu...
We have some code that given a property name uses reflection to implement a Comparer.
I would like to store a delegate/Func to get the value rather than paying the reflection price each time we need to get a value.
Given a class like this:
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
...
I have created a very simple dummy program to understand Delegates and events. In my below program I am simple calling a method.When I call a method, five methods are automatically calll with the help of Delegates and events.
Kindly take a look on my program and do let me know where I am wrong or right as I am using first time Delegates...
I have List<T> and I want to find two random name from that List<T> starting with some condition from List using .NET 2.0.
I know its very easy with LINQ but I am stuck with 2.0
I am wondering if I can do something like this
List<foo> list = new List<foo>();
List<foo> newlist = new List<foo>();
Random r = new Random();
list.Add(new ...
Why isn't it possible to assign events along with properties in object initializers in C#? It seems to be so natural to do so.
var myObject = new MyClass()
{
Property = value,
Event1 = actor,
// or
Event2 += actor
};
Or is there some trick that I don't know of?
...
If a parameter is a reference to an object, will the asynchronous invocation be passed the reference or a copy of the object (by marshalling)?
...
In my last post I have asked feedback of my code.Today I have also crated a simple dummy project.If you think that now I have basic knowledge of delegates and events, then please tell me some difficult task for delegates and events. Below is my code-
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DelegatesAndEvents.aspx.cs" I...