Friday, December 11, 2015

C# Interface

This sample code is my favorite way to demonstrate how interface work, I can see students in "20483 Programming in C#" are all understand why we have to implement interface and what is the meaning of contract to the implemented classes. 
 
 
using System;

namespace ConsoleApplication1
{
   interface IDataAccess
   {     
      void SelectTop10();
   }
   class OracleDataAccess : IDataAccess
   {
      public void SelectTop10(){
        Console.WriteLine("SELECT * FROM TABLE1 WHERE ROWNUM <= 10;");
      }

   }
   class SQLDataAccess : IDataAccess
   {
      public void SelectTop10(){
        Console.WriteLine("SELECT TOP 10 * FROM TABLE1;");
      }
   }
   class Program
   {
      static void Main(string[] args)
      {
         OracleDataAccess oracle = new OracleDataAccess();
         oracle.SelectTop10();
         IDataAccess sql = new SQLDataAccess();
         sql.SelectTop10();
      }
   }
}
 
Here is the output:-
 

C# Delegate with return value

I have written another simple Delegate code to share with students in "20483 Programming in C#", this code showing the delegate with parameters and return value and how we supply the parameters and receive the return value.
 
 
using System;

namespace EventDelegatePOC
{
   delegate int MyDelegate(string s);

   class Program
   {
      static int SayHello(string HelloMessage)
      {
          Console.WriteLine("Hello {0}", HelloMessage);
          return 100;
      }
      static int SayGoodBye(string GoodbyeMessage)
      {
          Console.WriteLine("Good Bye {0}", GoodbyeMessage);
          return -999;
      }
      static void Main(string[] args)
      {
          MyDelegate x = new MyDelegate(SayHello);
          MyDelegate y = new MyDelegate(SayGoodBye);

          int a = x("President");
          int b = y("Sayonara");

          Console.WriteLine("a = {0}", a);
          Console.WriteLine("b = {0}", b);
      }
   }
}
Here is the ouput:-

C# Event Delegate Tutorial

 
Here is the simple tutorial for understanding C# Event and Delegate, I believe the code explain by itself:
 
using System;

namespace EventDelegate2
{
   delegate void MyDelegate();

   class Program
   {
      static event MyDelegate myEvent;

      static void Main(string[] args)
      {
          myEvent += new MyDelegate(Sing);
          myEvent += new MyDelegate(Dance);

          myEvent.Invoke();

      }
       
      static void Sing()
      {
          Console.WriteLine("Sing");
      }


      static void Dance()
      {
          Console.WriteLine("Dance");
      }

    }
}
 
Here is the output:
 


Monday, November 09, 2015

Hyper-V and Virtual Box co-exists

If our computer has Hyper-V installed, when we run Oracle virtual box, we will get the error:- "VT-x/AMD-V hardware acceleration is not available on your system. Your 64-bit guest will fail to detect a 64-bit CPU and will not be able to boot."

The reason is one computer only can have one hypervision at a time, Hyper-V runs during Windows start up so Virtual box will always lose to Hyper-V.

To resolve this issue, we can disable Hyper-V when we intend to run VirtualBox or enable Hyper-V when we do not need to run VirtualBox.

To achieve this configuration, we have to use bcdedit command and reboot our computer:-

To run VirtualBox (Disabling Hyper-V): bcdedit /set hypervisorlaunchtype off
To run Hyper-V (No VirtualBox running): bcdedit /set hypervisorlaunchtype on

Thursday, July 02, 2015

Cisco VPN Freeze and BSOD

When there is any existing network connection such as Outlook, Dropdown, Communicator/Lync or any other network required software, if we connect Cisco VPN then we will get the whole Windows freeze then BSOD - Blue Screen of Death!

There is a solution for this problem -
1) Uninstall Cisco VPN
2) Download WinFix.exe and run it, once the WinFix complete will prompt Windows restart
3) Restart Windows
4) Download DNE Update, run it
5) Run installation of Cisco VPN

WinFix.exe and DNE Update can be downloaded from Cisco website at

How to fix DNE installation and other problem

https://www.citrix.com/go/lp/dne.html

Friday, May 22, 2015

Microsoft MOC Labs Free Download

All Microsoft trainings MOC Labs can be downloaded at
https://www.microsoft.com/learning/en-us/companion-moc.aspx


Tuesday, January 13, 2015

BizTalk 2013 Training

I offer BizTalk Server 2013 development course in Malaysia, anyone interested can contact me