c#
Equivalent of console.log in C#
Trace.WriteLine will do (and probably more methods from the Trace class). You can use a program called DebugView to real-time monitor the trace generated, or write to a log file using you web.config file.
Embedded statement cannot be a declaration or labeled statement
You have a statement (if or while, for example), right before the code you posted, without curly braces. For example: is correct, but the code below: will result in CS1023: Embedded statement cannot be a declaration or labeled statement. UPDATE The reason, according to @codefrenzy, is that the newly declared variable will immediately go out of scope, … Read more
What is a method group in C#?
A method group is the name for a set of methods (that might be just one) – i.e. in theory the ToString method may have multiple overloads (plus any extension methods): ToString(), ToString(string format), etc – hence ToString by itself is a “method group”. It can usually convert a method group to a (typed) delegate by using overload resolution – but not to … Read more
How can we generate getters and setters in Visual Studio?
Rather than using Ctrl + K, X you can also just type prop and then hit Tab twice.
How to format a string as a telephone number in C#
I have a string “1112224444′ it is a telephone number. I want to format as 111-222-4444 before I store it in a file. It is on a datarecord and I would prefer to be able to do this without assigning a new variable. I was thinking: but that does not seem to do the trick. … Read more
How do I exit a WPF application programmatically?
To exit your application you can call As described in the documentation to the Application.Shutdown method you can also modify the shutdown behavior of your application by specifying a ShutdownMode: Shutdown is implicitly called by Windows Presentation Foundation (WPF) in the following situations: When ShutdownMode is set to OnLastWindowClose. When the ShutdownMode is set to OnMainWindowClose. When a … Read more
c# Show Windows Form
This creates a new instance of type Form: Which, of course, is a blank form. It would appear that your type is called frmLogin. Normally this sounds like a variable name and not a class name, but the error you’re getting here tells me that it’s a class: Given that, then the quickest way to … Read more
Unexpected character encountered while parsing value
Possibly you are not passing JSON to DeserializeObject. It looks like from File.WriteAllText(tmpfile,… that type of tmpfile is string that contain path to a file. JsonConvert.DeserializeObject takes JSON value, not file path – so it fails trying to convert something like @”c:\temp\fooo” – which is clearly not JSON.