Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing Func with delegates C#

We are trying to move an application built in .NET 3.5 to 2.0 (reason to let our exe run on older machines with XP etc. which does not have 3.5)

While doing so everything is now stuck on one major problem Replacing Func with an old fashioned delegate (As Func is not available on 2.0). The code to be replaced is something like this.

private Func<object, string> someName1;
private static Func<object, string> someName2;

internal Func<object, string> someProperty
{
      get { return someName1?? (someName1= someName2); }
      set { someName1= value; }
}

Can some body please help me create 'someProperty' the way it is only by using delegates. Thanks in advance.

like image 460
Shubham Shrivastava Avatar asked Apr 18 '26 16:04

Shubham Shrivastava


1 Answers

public delegate void Action();
public delegate void Action<T>(T t);
public delegate void Action<T, U>(T t, U u);
public delegate void Action<T, U, V>(T t, U u, V v);

public delegate TResult Func<TResult>();
public delegate TResult Func<T, TResult>(T t);
public delegate TResult Func<T, U, TResult>(T t, U u);
public delegate TResult Func<T, U, V, TResult>(T t, U u, V v);
public delegate TResult Func<T, U, V, W, TResult>(T t, U u, V v, W w);
like image 182
Aseem Gautam Avatar answered Apr 21 '26 04:04

Aseem Gautam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!