Click here to Skip to main content
15,914,163 members
Home / Discussions / C#
   

C#

 
AnswerRe: I need some help using Exchange EWS with C# Pin
Dave Kreskowiak22-Jun-16 12:52
mveDave Kreskowiak22-Jun-16 12:52 
GeneralRe: I need some help using Exchange EWS with C# Pin
turbosupramk322-Jun-16 13:03
turbosupramk322-Jun-16 13:03 
GeneralRe: I need some help using Exchange EWS with C# Pin
Dave Kreskowiak22-Jun-16 17:56
mveDave Kreskowiak22-Jun-16 17:56 
GeneralRe: I need some help using Exchange EWS with C# Pin
turbosupramk323-Jun-16 4:41
turbosupramk323-Jun-16 4:41 
GeneralRe: I need some help using Exchange EWS with C# Pin
turbosupramk323-Jun-16 5:05
turbosupramk323-Jun-16 5:05 
QuestionVS2015 designer resizes my main form on different development PCs Pin
LenHodder22-Jun-16 6:53
LenHodder22-Jun-16 6:53 
AnswerRe: VS2015 designer resizes my main form on different development PCs Pin
BillWoodruff22-Jun-16 18:12
professionalBillWoodruff22-Jun-16 18:12 
GeneralRe: VS2015 designer resizes my main form on different development PCs Pin
LenHodder23-Jun-16 0:38
LenHodder23-Jun-16 0:38 
AnswerRe: VS2015 designer resizes my main form on different development PCs Pin
Luc Pattyn23-Jun-16 11:12
sitebuilderLuc Pattyn23-Jun-16 11:12 
QuestionWhenever code shows "Console.WriteLine..." replace with textbox Pin
Agewiz22-Jun-16 6:46
Agewiz22-Jun-16 6:46 
QuestionRe: Whenever code shows "Console.WriteLine..." replace with textbox Pin
Eddy Vluggen22-Jun-16 7:00
professionalEddy Vluggen22-Jun-16 7:00 
AnswerRe: Whenever code shows "Console.WriteLine..." replace with textbox Pin
Agewiz22-Jun-16 11:50
Agewiz22-Jun-16 11:50 
AnswerRe: Whenever code shows "Console.WriteLine..." replace with textbox Pin
Afzaal Ahmad Zeeshan22-Jun-16 7:12
professionalAfzaal Ahmad Zeeshan22-Jun-16 7:12 
PraiseRe: Whenever code shows "Console.WriteLine..." replace with textbox Pin
Eddy Vluggen22-Jun-16 8:04
professionalEddy Vluggen22-Jun-16 8:04 
GeneralRe: Whenever code shows "Console.WriteLine..." replace with textbox Pin
Agewiz22-Jun-16 12:02
Agewiz22-Jun-16 12:02 
AnswerRe: Whenever code shows "Console.WriteLine..." replace with textbox Pin
Afzaal Ahmad Zeeshan22-Jun-16 12:04
professionalAfzaal Ahmad Zeeshan22-Jun-16 12:04 
AnswerRe: Whenever code shows "Console.WriteLine..." replace with textbox Pin
BillWoodruff22-Jun-16 19:23
professionalBillWoodruff22-Jun-16 19:23 
I am not familiar with WinPhone C# programming, however, there is a general strategy I've often used to deal with a similar issue:

1. set a global flag that will determine where output goes: to Console, or TextBox

private const bool OutputToConsole = true; // true for debugging

2. in your code:
C#
private void SomeMethod(string blah)
{
    if(OutputToConsole)
    {
        Console.WriteLine("my blah is:" + blah);
    }
    else
    {
        someTextBox.Text = String.Format("my blah is: {0}", blah);
    }
}
This gets tiresome, but you can make this a bit easier to write by pre-defining template strings to use, and wrapping the whole thing up in an Extension Method for Type String:
C#
public static class StringExtensions
{
    // global setting for output target
    public static bool OutputToConsole = false;

    private static StringBuilder sb = new StringBuilder();

    public static void WriteString(this string content, bool toconsole, TextBox tbxtarget = null, string template = "")
    {
        sb.Clear();

        sb.Append((template == "")
            ? content
            : String.Format(template, content));

        if (OutputToConsole || toconsole || tbxtarget == null)
        {
            Console.WriteLine(sb.ToString());
        }
        else
        {
            tbxtarget.Text = sb.ToString();
        }
    }
}
So, now, if I have two TextBoxes on some Form, 'textBox1, and 'textBox2, and a Button, 'button1, I can:
C#
public const string template0 = "blah state is: {0}";

private void button1_Click(object sender, EventArgs e)
{
    "medium blah".WriteString(true, template: template0);
    "empty blah".WriteString(false, textBox2, template0);
}
The first call to 'WriteString writes "blah state is: medium blah" to the Console, the second writes "blah state is: empty blah" to 'textBox2.

Note: I assume Windows Phone programming supports Extension Methods; if that's not the case, let me know.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008

SuggestionRe: Whenever code shows "Console.WriteLine..." replace with textbox Pin
Richard Deeming23-Jun-16 2:09
mveRichard Deeming23-Jun-16 2:09 
GeneralRe: Whenever code shows "Console.WriteLine..." replace with textbox Pin
BillWoodruff23-Jun-16 3:05
professionalBillWoodruff23-Jun-16 3:05 
GeneralRe: Whenever code shows "Console.WriteLine..." replace with textbox Pin
Richard Deeming23-Jun-16 7:14
mveRichard Deeming23-Jun-16 7:14 
GeneralRe: Whenever code shows "Console.WriteLine..." replace with textbox Pin
BillWoodruff26-Jun-16 4:48
professionalBillWoodruff26-Jun-16 4:48 
QuestionDevExpress.XtraGrid.Views.Grid.GridView changing the data by Mouse Scrolling Pin
po_saa22-Jun-16 5:46
po_saa22-Jun-16 5:46 
AnswerREPOST Re: DevExpress.XtraGrid.Views.Grid.GridView changing the data by Mouse Scrolling Pin
Dave Kreskowiak22-Jun-16 6:01
mveDave Kreskowiak22-Jun-16 6:01 
QuestionMeaning of errors logged by FileSystemWatcher.Error Pin
srikrishnathanthri22-Jun-16 1:24
srikrishnathanthri22-Jun-16 1:24 
AnswerRe: Meaning of errors logged by FileSystemWatcher.Error PinPopular
Eddy Vluggen22-Jun-16 1:50
professionalEddy Vluggen22-Jun-16 1:50 

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.