Click here to Skip to main content
15,884,986 members
Home / Discussions / C#
   

C#

 
GeneralRe: Flow Options opinions Pin
Ennis Ray Lynch, Jr.26-Feb-09 7:18
Ennis Ray Lynch, Jr.26-Feb-09 7:18 
GeneralRe: Flow Options opinions Pin
ffowler26-Feb-09 7:20
ffowler26-Feb-09 7:20 
QuestionCan you pass a delegate that contains params object[] parameters to another degelate as a parameter? Pin
Steve Holdorf26-Feb-09 5:48
Steve Holdorf26-Feb-09 5:48 
GeneralRe: Can you pass a delegate that contains params object[] parameters to another degelate as a parameter? Pin
Steve Holdorf26-Feb-09 6:36
Steve Holdorf26-Feb-09 6:36 
AnswerRe: Can you pass a delegate that contains params object[] parameters to another degelate as a parameter? [modified] Pin
Steve Holdorf26-Feb-09 7:57
Steve Holdorf26-Feb-09 7:57 
GeneralRe: Can you pass a delegate that contains params object[] parameters to another degelate as a parameter? Pin
Alan N26-Feb-09 9:30
Alan N26-Feb-09 9:30 
GeneralRe: Can you pass a delegate that contains params object[] parameters to another degelate as a parameter? Pin
Steve Holdorf26-Feb-09 10:11
Steve Holdorf26-Feb-09 10:11 
GeneralRe: Can you pass a delegate that contains params object[] parameters to another degelate as a parameter? Pin
Steve Holdorf26-Feb-09 12:18
Steve Holdorf26-Feb-09 12:18 
Finished code:

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            TestManager tManager = new TestManager();

            Console.WriteLine("ProcessRequest1");

            tManager.Run1();

            Console.WriteLine("ProcessRequest2, returned value is: " + tManager.Run2());

            Console.ReadLine();

        }
    }
}

namespace ConsoleApplication1
{
    delegate object OuterDelegate (int p);
    delegate object InnerDelegate (params string[] list);

    class TestManager
    {
        public int ProcessRequest1(OuterDelegate DoSomethingWithResults, InnerDelegate GetData, params string[] sParams)
        {
            int iRet = Convert.ToInt32(GetData(sParams));

            iRet += 1;

            return Convert.ToInt32(DoSomethingWithResults(iRet));
        }

        public string DoSomethingWithResults(int i)
        {
            i += 4;

            return i.ToString();
        }

        public string DoNothingWithResults(int i)
        {
            return i.ToString();
        }

        public object GetData(params string[] list)
        {
            int iReturn;

            iReturn = (Convert.ToInt32(list.GetValue(0))) + (Convert.ToInt32(list.GetValue(1)));

            return iReturn;
        }

        public int ProcessRequest2(OuterDelegate DoNothingWithResults, InnerDelegate GetData, params string[] sParams)
        {
            int iRet = Convert.ToInt32(GetData(sParams));

            return iRet;
        }
        
        internal void Run1()
        {
            string [] sArray = { "1", "2" };
            Console.WriteLine("Not returning anything, results: " + ProcessRequest1(DoSomethingWithResults, GetData, sArray));
        }

        internal string Run2()
        {
            string[] sArray = { "4", "5" };
            return Convert.ToString(ProcessRequest2(DoNothingWithResults, GetData, sArray));
        }
    }

}

AnswerRe: Can you pass a delegate that contains params object[] parameters to another degelate as a parameter? Pin
Ennis Ray Lynch, Jr.26-Feb-09 7:02
Ennis Ray Lynch, Jr.26-Feb-09 7:02 
GeneralRe: Can you pass a delegate that contains params object[] parameters to another degelate as a parameter? Pin
led mike26-Feb-09 7:07
led mike26-Feb-09 7:07 
AnswerRe: Can you pass a delegate that contains params object[] parameters to another degelate as a parameter? Pin
Luc Pattyn26-Feb-09 8:02
sitebuilderLuc Pattyn26-Feb-09 8:02 
GeneralRe: Can you pass a delegate that contains params object[] parameters to another degelate as a parameter? Pin
Steve Holdorf26-Feb-09 8:20
Steve Holdorf26-Feb-09 8:20 
AnswerRe: Can you pass a delegate that contains params object[] parameters to another degelate as a parameter? Pin
Luc Pattyn26-Feb-09 8:38
sitebuilderLuc Pattyn26-Feb-09 8:38 
Questionhow to apply zoom to usercontrol... Pin
priyareguri26-Feb-09 5:10
priyareguri26-Feb-09 5:10 
AnswerRe: how to apply zoom to usercontrol... [modified] Pin
Calin Tatar26-Feb-09 5:25
Calin Tatar26-Feb-09 5:25 
GeneralRe: how to apply zoom to usercontrol... Pin
priyareguri27-Feb-09 4:43
priyareguri27-Feb-09 4:43 
QuestionCrystal report question Pin
E_Gold26-Feb-09 3:56
E_Gold26-Feb-09 3:56 
AnswerRe: Crystal report question Pin
led mike26-Feb-09 4:37
led mike26-Feb-09 4:37 
AnswerRe: Crystal report question Pin
DaveyM6926-Feb-09 4:51
professionalDaveyM6926-Feb-09 4:51 
GeneralRe: Crystal report question Pin
E_Gold26-Feb-09 11:04
E_Gold26-Feb-09 11:04 
GeneralRe: Crystal report question Pin
led mike26-Feb-09 11:24
led mike26-Feb-09 11:24 
Questiondynamically add a flash object to a C# desktop application Pin
Zap-Man26-Feb-09 3:54
Zap-Man26-Feb-09 3:54 
AnswerRe: dynamically add a flash object to a C# desktop application Pin
led mike26-Feb-09 4:34
led mike26-Feb-09 4:34 
GeneralRe: dynamically add a flash object to a C# desktop application Pin
Zap-Man26-Feb-09 5:05
Zap-Man26-Feb-09 5:05 
GeneralRe: dynamically add a flash object to a C# desktop application Pin
EliottA26-Feb-09 5:42
EliottA26-Feb-09 5:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.