Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Experimenting with Func someDel -- problem setting up a test situation (VS2012 -- winform)

$
0
0

I am trying to get the hang of using Func<........> something, so I created a simple test class that uses Func<.....> in a simple winform app.  Form1 contains a button and 2 textboxes.  Textbox1 contains some default text "testing".   I want to append some default text to "testing" when I click the button and display the appended (concatenated) text (something like "testing this is a test") in textbox2, but I want to use my appendString class.   How could I write some code in the button click event that would use class appendString to do the text append?   (the goal is to learn how to use Func<.....>) 

Here is my sample class.  If this class is too discombobulated -- I am open to suggestions for a better test class

	class appendString
    {
        private readonly Func<string, string> _strAppend;

        public appendString(Func<string, string> strAppend)
        {
            _strAppend = strAppend;            
        }

        public string appendText(string inputText)
        {
            return _strAppend(inputText);
        }
    }

Thanks

 

Rich P



Viewing all articles
Browse latest Browse all 31927

Trending Articles