Howto access a protected method

Here is a small code snippet about howto access a protected method of a class:

Code Snippet
  1. public class OriginalClass
  2. {        
  3.     protected int OrginalProtectedMethod()
  4.     {
  5.         return 0;
  6.     }
  7. }
  8. public class MyDescClass : OriginalClass
  9. {
  10.     public int MyMethod() {
  11.         return OrginalProtectedMethod();
  12.     }
  13. }
  14.  
  15. // access the "protected method"
  16. var md = new MyDescClass();
  17. var result = md.MyMethod();

Howto show the resize grip (window drag handle)

If you want to display the the drag handle in the lower right corner of the Window you have to set the ResizeMode Window property like that:

Code Snippet
  1. <Window
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. ResizeMode="CanResizeWithGrip">

This is the result:

resizegrip

Visual Studio code selection as HML

I was looking for a possibility to copy selected Visual Studio code as HTML to publish code easily.

I am using Windows Live Writer and WordPress. There is a plugin called "Paste As Visual Studio Code".

Here you can download this plugin.

Install this plugin, start Windows Live Writer, copy some code from Visual Studio IDE, switch to tab “Insert” and paste it into an Windows Live Writer article clicking the plugin button.

pasteasvisualstudiocode

Outputdebugstring in .NET / Visual Studio / C# / WPF

In my old Delphi developer days I used OutputDebugString() to track problems or elapsed time.
In .NET you can use the System.Diagnostics.Debug class.

You have to run the project in debug mode.

Code Snippet
  1. private void ReadFirstFile(string filename1)
  2. {
  3.     StatusText = "Reading file 1";
  4.     Stopwatch watch = new Stopwatch();
  5.     watch.Start();
  6.     using (StreamReader file1 = new StreamReader(filename1))
  7.     {
  8.         while (!file1.EndOfStream)
  9.         {
  10.             sc1.Add(file1.ReadLine());
  11.         }
  12.     }
  13.     watch.Stop();
  14.     System.Diagnostics.Debug.WriteLine("Time spent reading file 1: " + watch.Elapsed);
  15. }

MSDN link: http://msdn.microsoft.com/en-us/library/6x31ezs1.aspx